February 7, 2016

Install update package programmatically in Sitecore

If you want to install update package in Sitecore, you just need to use “Sitecore.Update”
assembly for this activity.

bool hasPostAction;
string historyPath;

ILog log = LogManager.GetLogger("root"
);
           
XmlConfigurator.Configure((XmlElement)ConfigurationManager.GetSection("log4net"));
using (new SecurityDisabler
())
{
DiffInstaller installer = new DiffInstaller(UpgradeAction.Upgrade);
MetadataView view = UpdateHelper.LoadMetadata(path);
List<ContingencyEntry> entries = installer.InstallPackage(path,   Sitecore.Update.Utils.InstallMode.Install, log, out hasPostAction, out
historyPath);
installer.ExecutePostInstallationInstructions(path, historyPath, Sitecore.Update.Utils.
InstallMode.Install, view, log, ref entries);
}

No comments:

Post a Comment