Question: Using usync first boot pattern as an alternative to packageMigrationPlan??
I wonder if it's ever crossed your path to perhaps use UsyncFirst boot pattern as part of a package migration plan to install a starter set of doctypes/datatypes/templates?
I seem to find myself constantly battling with the foibles of the legacy package migration https://docs.umbraco.com/umbraco-cms/extending/packages/creating-a-package
Most especially templates where the view should come from the nuget package (as RCL) but is then immediately overrwritted by the template in plain text in the package.xml file process.. Not to mention that docytpes can be updated/merged via the package.xml but datatypes if existing are just ignored.
So I find myself reinventing the uSync wheel and programatically manipulating datatypes in the migration..
var footerBlockConfiguration = igFooterBlockList.Configuration as BlockListConfiguration;
var footerBlocks = footerBlockConfiguration.Blocks.ToList();
// Login widget
IContentType loginContentType = _contentTypeService.Get(loginKey);
IContentType loginSettingsContentType = _contentTypeService.Get(loginSettingsKey);
if (loginContentType is null || loginSettingsContentType is null) { errors.Add("login", "login content types not found"); }
// check we don't already have the block in the config somehow
if (!errors.ContainsKey("login") && !footerBlocks.Exists(x => x.ContentElementTypeKey == loginContentType.Key))
{
footerBlocks.Add(new BlockListConfiguration.BlockConfiguration
{
ContentElementTypeKey = loginContentType.Key,
SettingsElementTypeKey = loginSettingsContentType.Key,
Label = "Login"
});
}
just thought this could be a migration plan that takes a set of uSync config files from the package and processes them ?? (bit like first boot, but just as part of a migration plan) and I can stand on the shoulders of giants.. ;-)
Hi,
Yes, in the past i've used bit of uSync to do this (LocalGov starter kit many moons ago). although it does require a little plumbing.
in theory. a) you could export everything from your starter kit/package, and either merge it into one big file or have loads of individual files somewhere in your package.
-
in a package migration you could load the xml from somewhere (resource like the core package migration's do or a folder).
-
you could then use uSync to import the xml.
If you had one merged xml file of all the usync files you would need to split it out but then you could feed each bit into the uSync service it has an ImportElement/ImportXML method that will just import something.
- or you could be cleverer (and reduce the need to install all uSync in the package) and use the uSync.Core package only. This has serializers in it. These are the bits that do the work, and they can just be passed XElement objects and import stuff.
its been a while since i did this with a package, so it might be a bit diffrent since i last tried. but in theory its all possible
Thanks for the insight! Though thinking back to the example above.. where i want to add an additional block into a blocklist datatype can uSync do a merge there? Can you do fancy merging in the deserialiser, where the root is the current setting (and not usync Roots)