Post Install Publisher

One thing that frustrates me when dealing with large Sitecore packages is not knowing where items have been installed and not wanting to do a full site publish on a live site with over 30,000 items, and possible draft content.

So i have put together a simple event handler to publish all the items in the package, to all targets in all languages once the package has finished installing.

nothing to complicated, code and configuration below, or for simplicity you can download the sitecore package here or from the Sitecore Marketplace, tested against Sitecore v7/v8


using Sitecore.Data;
using Sitecore.Data.Events;
using Sitecore.Data.Items;
using Sitecore.Data.Managers;
using Sitecore.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Arktouros_PostInstallPublish
 public class EventHandler
 public virtual void PublishItems(object sender, System.EventArgs args)
 SitecoreEventArgs evntArgs = (SitecoreEventArgs)args;
 Sitecore.Install.Events.InstallationEventArgs installEventArgs = (Sitecore.Install.Events.InstallationEventArgs)evntArgs.Parameters[0];

 Database master = Sitecore.Configuration.Factory.GetDatabase("master");
 //get publishing targets
 List targetDbs = new List();
 foreach (var trgt in Sitecore.Publishing.PublishManager.GetPublishingTargets(master))
 if (!string.IsNullOrEmpty(trgt["Target Database"]))
 Database target = Sitecore.Configuration.Factory.GetDatabase(trgt["Target Database"]);
 if (target != null)
 //get languages
 Sitecore.Collections.LanguageCollection langs = LanguageManager.GetLanguages(master);
 List lstToPublish = new List();
 foreach (var i in installEventArgs.ItemsToInstall)
 Item toPublish = master.GetItem(i.ItemID);
 if (toPublish != null)
 //order by axes so we make sure we publish any parent nodes first
 lstToPublish = lstToPublish.OrderBy(x => x.Axes.Level).ToList();
 //start publish job for each item, not the most efficient, but only way
 foreach (Item i in lstToPublish)
 Sitecore.Publishing.PublishManager.PublishItem(i, targetDbs.ToArray(), langs.ToArray(), false, false, false);
 catch (Exception ex)
 Sitecore.Diagnostics.Log.Error("Arktouros - PublishAfterInstall Failed: " + ex.Message, ex);


<configuration xmlns:patch="" xmlns:x="">
 <sitecore database="SqlServer">
 <events timingLevel="custom">
 <event name="packageinstall:items:ended">
 <handler type="Arktouros_PostInstallPublish.EventHandler, Arktouros_PostInstallPublish" method="PublishItems" />

All done, enjoy