Clients i have always ask for a method of associating content with a particular release. Generally speaking we’d go with a Unicorn deploy once configuration, Sitecore Sidekick (which obviously i’m quite partial to), or a manual package install post-build step. All of these methods have their strength and drawbacks. The main drawback with these methods is controlling when items should be added. For example if you want content to be added once and then never added again regardless it’s a hassle for Unicorn because you’ll need to remove the configuration tracking those items and it’s a hassle for Sidekick for the same reason, you’ll need to remove the scripting kicking off the content transfer for subsequent releases. Additionally, both these methods involve quite a bit of configuration scripting to both your solution and your build/release pipelines.

Automating packages

My proposal to fix this come in the form of automating package installation with a descriptor for when the package should be installed. Based on a few techniques I’ve used in the past that have been pretty effective to make this process as simple and seamless as possible.

This is facilitated through a nuget package found here.

No configuration needed (beyond the base configuration needed for the module). No additions to your build/release pipeline. Full control over when/if a package is installed. Full control over dependencies if you have packages that require other packages to be installed first Full control over the type of package install method being used

Using packages from an embedded resource

This method minimizes the effort needed to facilitate an automatic package deployment. Note that this method will incur a memory cost based on the size of the package so be careful of your package sizes when using this method.

The package is embedded in a dll file. This is nice because every build/release process ever handles dlls easily A descriptor (c# poco: PackageAutoloaderDescriptor) controls when a package should be applied The package is installed as part of the initialize pipeline so you’re guaranteed the package content is installed before Sitecore is usable

A simple Example

public class DemoDescriptor : PackageAutoloaderDescriptor { public void Process(PipelineArgs args) { } public override string PackageNamespace => "PackageAutoloaderDemo.demo.zip"; public override List Requirements => new List() { new DescriptorItemRequirements() { Database = "master", ItemId = new ID("{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}") } }; }

Using packages from the filesystem

Thanks to Robin Hermanussen for the comment suggesting to add this feature.

This allows automatically installing packages in the same way as above except instead of referencing a namespace for an embedded resource package you can have it install a package from a filepath. This saves on memory consumption and allows us to install much larger files without worry. Note that this method will need to have a build/release method of delivering the Sitecore package to your server

The package is delivered to the server This can be located anywhere, not simply the App_Data/packages folder that standard Sitecore uses A descriptor (c# poco: PackageFileloaderDescriptor) controls when a package should be applied The package is installed as part of the initialize pipeline so you’re guaranteed the package content is installed before Sitecore is usable

A simple example

public class DemoDescriptor2 : PackageFileLoaderDescriptor { public override IItemInstallerEvents ItemInstallerEvents => new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode.Overwrite, MergeMode.Undefined)); public override List Requirements => new List() { new DescriptorItemRequirements() { Database = "master", ItemId = new ID("{190B1C84-F1BE-47ED-AA41-F42193D9C8FC}") } }; public override string RelativeFilePath => "/PackageAutoloader/demo2.zip"; }

Usage instructions

You can read the documentation on setting up Package Autoloader here