kevinobee/Sitecore.Ship — pull request #24 by mikeedwards83 (2014-06-03 11:32:59+00:00)
Title: Post Installation Steps Support

I have added support for post installation steps after a package has been installed. This code was developed by looking at Sitecore.Update.InstallUpdatePackage, in particular these two methods:

protected void ExecutePostStep(MetadataView view)
{
try
{
if (string.IsNullOrEmpty(this.InstallationHistoryRoot) || !Directory.Exists(this.InstallationHistoryRoot))
throw new Exception("Cannot execute post installation action because installation data not found.");
this.ShowInstallationLog(this.LoadInstallationLog());
this.countOfCommands = view.CommandsCount;
this.commandsProcessedCount = this.countOfCommands;
List entries = UpdateHelper.LoadEntries(this.InstallationHistoryRoot);
this.SetUpdatingText("Executing post installation actions.");
this.Response.Flush();
this.ExecutePostStep(entries, view);
}
finally
{
this.SetHistoryPath(this.InstallationHistoryRoot);
}
}

protected void ExecutePostStep(List entries, MetadataView view)
{
string installationHistoryRoot = this.InstallationHistoryRoot;
DiffInstaller diffInstaller = new DiffInstaller(this.UpgradeAction);
try
{
diffInstaller.ExecutePostInstallationInstructions(this.PackagePath, installationHistoryRoot, this.InstallMode, view, (ILog) this, ref entries);
this.FinalizeInstallation();
}
catch (Exception ex)
{
this.WriteSupportInstructions(installationHistoryRoot, ex);
this.ShowInstallationLog();
this.EnsureProgressFailed();
this.Response.Flush();
}
finally
{
UpdateHelper.SaveInstallationMessages(entries, installationHistoryRoot);
UpdateHelper.SaveInstallationLog(this.logEntries, installationHistoryRoot);
}
}