I’m sure some people have noticed that the Sitecore Package Designer contains a “Post Step” field. How can that be used and what for?
The Post Step lets you input a method to be run after the package has been installed.
To make it work, you need a class that either already exists on the target Sitecore or is in the assembly that is installed with the package.
The class should implement Sitecore.Install.Framework.IPostStep interface that has a single RunPostStep(ITaskOutput output, NameValueCollection metaData) method.
Your code will run in the “shell” site. What’s more important, it will run in the background thread, so you cannot use the ClientResponse or SheerResponse methods. Instead, the output parameter provides a few basic methods of interaction, such as showing the alert box or a confirm dialog.
Below is a trivial example that renames the home item after the package installation:
public class Sitecore6Patch2 : IPostStep { public void Run(ITaskOutput output, NameValueCollection metaData) { var home = Context.ContentDatabase.GetItem("/sitecore/content/home"); if (home != null) { home.Name = "Home upgraded"; } } }
Note: the above example is for Sitecore 6. In Sitecore 5, your class should have a parameterless RunPostStep method instead, which is also supported in Sitecore 6 for compatibility purposes.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.