Custom Post Install Steps – Installing Sitecore from a Clean Slate Using SIM

A question popped up on Sitecore StackExchange asking how to remove the default items when installing using SIM. As we all know, Sitecore installs some sample items and provides the “lady with the phone” sample homepage. Normally I just ignore them, the items will be there in the deployed solution but since they are not referenced anywhere we don’t really care.

Anyway, there are no steps in SIM to clean the default items from the install of Sitecore. I’ve previously blogged about running scripts using PowerShell and TDS Post Deploy actions, but that requires SPE to be installed and the scripts to be deployed but TDS generates .update packages so that would be no good to install with SIM. However Sitecore packages themselves can contain Post Install Steps, they are not TDS specific – post install steps are used as part of the upgrade process or when installing packages such as WebForms For Marketers for example.

So why not create a custom package with a Post InstallStep to delete the default (or any) items?

Below is a sample post step with parameters passed through for the database and items to delete. It’s very simple code, but shows you how you can create your own post install step and add a reference to it in a Sitecore package and then run whatever logic you need.

Package with Post Install Step

Create the following Post Install Step, adding a reference to Sitecore.Kernel.dll in your project:

    using Sitecore.Configuration;
    using Sitecore.Data;
    using Sitecore.Data.Items;
    using Sitecore.Diagnostics;
    using Sitecore.Install.Framework;
    using Sitecore.Web;
    using System.Collections.Specialized;

    namespace Sitecore.CleanSlate
        public class PostStepDelete : IPostStep
            public void Run(ITaskOutput output, NameValueCollection metaData)
                var parameters = WebUtil.ParseParameters(metaData["Attributes"], '|');

                Database db = Factory.GetDatabase(parameters["database"]);
                string[] items = parameters["items"].Split(',');

                foreach (var i in items)
                    Item item = db.GetItem(i);
                    if (item != null)
                        Log.Info("Post Install Delete : " + item.Paths.FullPath, this);

Then create a package using the Package Designer.

  • From the ribbon, select Files statically and add the DLL containing the Post Install step
  • From the System section, enter the details of the Post Step, e.g. Sitecore.CleanSlate.PostStepDelete, Sitecore.CleanSlate
  • Add the database and items to delete as attributes, e.g.
    • database : master
    • items : {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9},{4D8A1C4D-1351-4DD1-A502-0660F01FEDC7},{14030E9F-CE92-49C6-AD87-7D49B50E42EA},{1936B96E-DA1F-4A3A-8AAF-8C46268E2D84},{9EB73C4C-1AF7-47C7-85B8-93E08176D4D2},{CE4ADCFB-7990-4980-83FB-A00C1E3673DB},{885B8314-7D8C-4CBB-8000-01421EA8F406},{8AE1C245-A4FA-46AE-9B35-4FBC15F63169},{73BAECEB-744D-4D4A-A7A5-7A935638643F},{A5BC37E7-ED96-4C1E-8590-A26E64DB55EA}
  • Generate the package zip


When installing Sitecore using SIM, on the Custom Packages step Add Package and select the zip that was generated earlier and then continue the install as normal.


This is not a SIM specific package, installing it via the Sitecore Installation Wizard will also produce the same result.

What does this delete?

The package has been tested with Sitecore 8.1.3 and 8.2 but it should work with most versions of Sitecore since the item guids should be the same across all versions but please verify if you’re on a different version.

The guids specified as the items in the attributes relate to the following items:

    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} - /sitecore/content/Home
    {4D8A1C4D-1351-4DD1-A502-0660F01FEDC7} - /sitecore/media library/Default Website
    {14030E9F-CE92-49C6-AD87-7D49B50E42EA} - /sitecore/layout/Layouts/Sample Layout
    {1936B96E-DA1F-4A3A-8AAF-8C46268E2D84} - /sitecore/layout/Renderings/Sample
    {9EB73C4C-1AF7-47C7-85B8-93E08176D4D2} - /sitecore/layout/Sublayouts/Sample Datasource Sublayout
    {CE4ADCFB-7990-4980-83FB-A00C1E3673DB} - /sitecore/layout/Sublayouts/Sample Inner Sublayout
    {885B8314-7D8C-4CBB-8000-01421EA8F406} - /sitecore/layout/Sublayouts/Sample Sublayout
    {8AE1C245-A4FA-46AE-9B35-4FBC15F63169} - /sitecore/layout/Placeholder Settings/content
    {73BAECEB-744D-4D4A-A7A5-7A935638643F} - /sitecore/templates/Sample
    {A5BC37E7-ED96-4C1E-8590-A26E64DB55EA} - /sitecore/system/Workflows/Sample Workflow

Add or remove items as required.

Obviously, the Post Install Step can contain whatever code you want – add items, delete items, move items, transform items or go as crazy as you want.

Package Download

You can download the package containing the above from here:

If you wish to edit the list of items, then open Sitecore package using an archive tool like 7zip, extract Sitecore\\metadata\items file, edit using a text editor and then replace the modified file into the archive.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s