protected override void ProcessRecord() { string fileName = Path; PerformInstallAction( () => { if (IncludeProject.IsPresent) { Project.SaveProject = true; } if (!System.IO.Path.IsPathRooted(fileName)) { fileName = FullPackagePath(fileName); } IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents events = new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode, MergeMode)); context.AddAspect(events); IFileInstallerEvents events1 = new DefaultFileInstallerEvents(true); context.AddAspect(events1); var installer = new Installer(); installer.InstallPackage(fileName, context); }); }
private void InstallPackage(FileInfo file) { // in case file disappeared since retrieved file.Refresh(); if (!file.Exists) { return; } FridayLog.Info(AutoPackages.FeatureName, $"Install auto package (Skip on conflicts): {file.FullName}"); using (new SecurityDisabler()) { var context = new SimpleProcessingContext(); // IItemInstallerEvents type cast is essential var items = (IItemInstallerEvents) new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode.Skip, MergeMode.Undefined)); context.AddAspect(items); // IFileInstallerEvents type cast is essential var files = (IFileInstallerEvents) new DefaultFileInstallerEvents(false); context.AddAspect(files); new Installer().InstallPackage(file.FullName, context); new Installer().InstallSecurity(file.FullName, context); var previewContext = Installer.CreatePreviewContext(); var packageReader = new PackageReader(file.FullName); var view = new MetadataView(previewContext); var metadataSink = new MetadataSink(view); metadataSink.Initialize(previewContext); packageReader.Populate(metadataSink); new Installer().ExecutePostStep(view.PostStep, previewContext); } }
public void Install() { Context.SetActiveSite("shell"); using (new SecurityDisabler()) { using (new SyncOperationContext()) { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents events = new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode.Overwrite, MergeMode.Clear)); context.AddAspect(events); IFileInstallerEvents events1 = new DefaultFileInstallerEvents(true); context.AddAspect(events1); var inst = new Installer(); inst.InstallPackage(FileUtil.MapPath(FileName), context); ISource <PackageEntry> source = new PackageReader(FileUtil.MapPath(FileName)); var previewContext = Installer.CreatePreviewContext(); var view = new MetadataView(previewContext); var sink = new MetadataSink(view); sink.Initialize(previewContext); source.Populate(sink); inst.ExecutePostStep(view.PostStep, previewContext); } } }
/// <summary> /// If verification fails, the package will be installed by this method. /// </summary> /// <param name="packageFileName">The file name of the Sitecore Package located in Sitecore's configured Packages folder.</param> protected virtual void InstallPackage(string packageFileName) { var filePath = $"{Sitecore.Configuration.Settings.DataFolder}/packages/{packageFileName}"; using (new SecurityDisabler()) { var installMode = Details.InstallMode; if (installMode == InstallMode.Undefined) { installMode = PackageVerifierConfiguration.Current.DefaultInstallMode; } var mergeMode = Details.MergeMode; if (mergeMode == MergeMode.Undefined) { mergeMode = PackageVerifierConfiguration.Current.DefaultMergeMode; } using (new SyncOperationContext()) { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents events = new DefaultItemInstallerEvents( new BehaviourOptions(installMode, mergeMode)); context.AddAspect(events); IFileInstallerEvents events1 = new DefaultFileInstallerEvents(true); context.AddAspect(events1); var installer = new Sitecore.Install.Installer(); installer.InstallPackage(MainUtil.MapPath(filePath), context); } } }
public ActionResult InstallPackage() { StringBuilder ret = new StringBuilder(); Stopwatch sw = new Stopwatch(); sw.Start(); try { using (new SecurityDisabler()) using (new SyncOperationContext()) { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents events = new DefaultItemInstallerEvents( new BehaviourOptions(InstallMode.Overwrite, MergeMode.Undefined)); context.AddAspect(events); IFileInstallerEvents events1 = new DefaultFileInstallerEvents(true); context.AddAspect(events1); Sitecore.Install.Installer installer = new Sitecore.Install.Installer(); installer.InstallPackage(MainUtil.MapPath(@"C:\inetpub\wwwroot\demo1.local\App_Data\packages\bigtst.zip"), context); } } catch (Exception e) { ret.Append(e.ToString()); } finally { ret.Append($"\n\n{sw.Elapsed.TotalSeconds}"); } return(Content(ret.ToString())); }
protected override void ProcessRecord() { if (DisableIndexing.IsPresent) { WriteWarning($"The parameter {nameof(DisableIndexing)} is no longer used. The functionality has been removed from the Sitecore platform."); } var fileName = Path; PerformInstallAction(() => { if (!System.IO.Path.IsPathRooted(fileName)) { var packagePath = FullPackagePath(fileName); WriteVerbose($"Path is not rooted. Updating to {packagePath}."); if (!FileUtil.Exists(packagePath)) { packagePath = System.IO.Path.GetFullPath( System.IO.Path.Combine( CurrentProviderLocation("FileSystem").ProviderPath, fileName)); WriteVerbose($"Path could not be found. Updating to {packagePath}."); if (!FileUtil.Exists(packagePath)) { WriteVerbose("Path still could not be found. Check that the file actually exists in the Sitecore package directory."); } } fileName = packagePath; } if (!ShouldProcess(fileName, "Install package")) { return; } using (new Sitecore.Data.BulkUpdateContext()) { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents instance1 = new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode, MergeMode)); context.AddAspect(instance1); IFileInstallerEvents instance2 = new DefaultFileInstallerEvents(true); context.AddAspect(instance2); var installer = new Installer(); installer.InstallPackage(fileName, context); ISource <PackageEntry> source = new PackageReader(fileName); var previewContext = Installer.CreatePreviewContext(); var view = new MetadataView(previewContext); var metadataSink = new MetadataSink(view); metadataSink.Initialize(previewContext); source.Populate(metadataSink); installer.ExecutePostStep(view.PostStep, previewContext); } }); }
public void InstallPackage() { var filepath = ""; if (System.Text.RegularExpressions.Regex.IsMatch(Settings.DataFolder, @"^(([a-zA-Z]:\\)|(//)).*")) { //if we have an absolute path, rather than relative to the site root filepath = Settings.DataFolder + @"\packages\DemandbasePackage.zip"; } else { filepath = HttpRuntime.AppDomainAppPath + Settings.DataFolder.Substring(1) + @"\packages\DemandbasePackage.zip"; } try { GeneratePackage(filepath); int count = 0; while (true) { if (count > 15) { throw new Exception("Demandbase package extracted to data folder packages however appears to be locked, unlock this file and recycle the app pool."); } if (!IsFileLocked(new FileInfo(filepath))) { using (new SecurityDisabler()) { using (new SyncOperationContext()) { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents events = new DefaultItemInstallerEvents( new BehaviourOptions(InstallMode.Overwrite, MergeMode.Undefined)); context.AddAspect(events); IFileInstallerEvents events1 = new DefaultFileInstallerEvents(true); context.AddAspect(events1); Sitecore.Install.Installer installer = new Sitecore.Install.Installer(); installer.InstallPackage(MainUtil.MapPath(filepath), context); break; } } } else { Thread.Sleep(1000); } } } catch (Exception e) { Log.Error("Demandbase was unable to initialize", e, this); } }
public void Install([NotNull] string fileName) { try { Context.SetActiveSite("shell"); using (new SecurityDisabler()) { using (new ProxyDisabler()) { using (new SyncOperationContext()) { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents itemInstallerEvents = new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode.Overwrite, MergeMode.Clear)); context.AddAspect(itemInstallerEvents); IFileInstallerEvents fileInstallerEvents = new DefaultFileInstallerEvents(true); context.AddAspect(fileInstallerEvents); var installer = new Installer(); installer.InstallPackage(FileUtil.MapPath(fileName), context); ISource <PackageEntry> source = new PackageReader(FileUtil.MapPath(fileName)); var previewContext = Installer.CreatePreviewContext(); var view = new MetadataView(previewContext); var sink = new MetadataSink(view); sink.Initialize(previewContext); source.Populate(sink); installer.ExecutePostStep(view.PostStep, previewContext); } } } File.WriteAllText(fileName + ".log", @"OK"); } catch (Exception ex) { File.WriteAllText(fileName + ".log", @"Error" + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); } }
public void InstallZipPackage(string path, Credentials credentials) { Login(credentials); // Fallback to temp folder if (File.Exists(Server.MapPath(path))) { path = Server.MapPath(path); } else { path = Server.MapPath("/temp/" + path); } var file = new FileInfo(path); if (!file.Exists) { throw new ApplicationException(string.Format("Cannot access path '{0}'.", path)); } Sitecore.Context.SetActiveSite("shell"); using (new SecurityDisabler()) { using (new ProxyDisabler()) { using (new SyncOperationContext()) { IProcessingContext context = new SimpleProcessingContext(); // IItemInstallerEvents events = new DefaultItemInstallerEvents(new Sitecore.Install.Utils.BehaviourOptions(Sitecore.Install.Utils.InstallMode.Overwrite, Sitecore.Install.Utils.MergeMode.Undefined)); context.AddAspect(events); IFileInstallerEvents events1 = new DefaultFileInstallerEvents(true); context.AddAspect(events1); var installer = new Sitecore.Install.Installer(); installer.InstallPackage(path, context); } } } }
// note: the dialog option is only because we're being lazy about what we pass along public InstallPackageResult InstallPackage(string packageName = null, bool publish = false) { //[FromUri]DynamicGetRequest request var ret = new InstallPackageResult(); var installLog = ""; //TODO: Look into the cloning mechanism fo SC 9 //new ForceCloneAccept().RegisterEvent(false); //new SitemapFieldValues().RegisterEvent(false); // string packagePath = string.Concat(Sitecore.Configuration.Settings.DataFolder, "\\packages\\", packageName); //string packagePath = @"C:\_Projects\HenrySchein.CMS.Web\data\packages\Unnamed Package.zip"; //TODO: figure out the return codes, and how to return them i.e throw HTTP error codes, or anything else if (packageName == null) { ret.Message = "ERROR: url param not found"; ret.Successful = false; return(ret); } if (string.IsNullOrWhiteSpace(packageName)) { ret.Message = "ERROR: url param is empty"; ret.Successful = false; return(ret); } // TODO: huh? if (!File.Exists(packagePath)) { ret.Message = "ERROR: file not found"; ret.Successful = false; return(ret); } //Sitecore.Configuration.Settings.Indexing.Enabled = false; try { Sitecore.Context.SetActiveSite("shell"); using (new SecurityDisabler()) { //Proxy disabler has been deprecated in SC 9 //using (new ProxyDisabler()) //{ using (new SyncOperationContext()) { var context = new SimpleProcessingContext(); var itemInstallerEvents = new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode.Merge, MergeMode.Merge)); context.AddAspect(itemInstallerEvents); var fileInstallerEvents = new DefaultFileInstallerEvents(true); context.AddAspect(fileInstallerEvents); new Sitecore.Install.Installer().InstallPackage(MainUtil.MapPath(packagePath), context); } //} } if (publish) { List <Item> items = GetItemsFromPackage(packagePath, installLog); /* * var items = new List<Item>(); * * // Get items from package * PackageProject packageProject = PackageGenerator.NewProjectFromPackage(packagePath); * var sources = from n in packageProject.Sources where n is ItemSource select n; * foreach (ItemSource source in sources) * { * if (source != null) * { * * foreach (var entry in source.Name) * { * //ItemReference reference = ItemReference.Parse(entry); * //Item item = reference.GetItem(); * //items.Add(item); * } * * } * } */ // TODO: make this confurable? string[] targets = new string[] { "web" }; foreach (string target in targets) { var targetDatabase = Sitecore.Configuration.Factory.GetDatabase(target); installLog += "INSTALL PUBLISH to: " + targetDatabase.Name + "<br>"; // Publish items foreach (var item in items) { installLog += "INSTALL PUBLISHING: " + item.Paths.FullPath + "<br>"; PublishManager.PublishItem(item, new[] { targetDatabase }, new[] { item.Language }, true, false); } } } /* * string packageFile = @"C:\_Projects\HenryScheinSitecore\Development\Developers\Mickey\HenrySchein.CMS.Web\data\packages\test package.zip"; * TaskMonitor Monitor = new TaskMonitor(); * Monitor.Start(new ThreadStart(new AsyncHelper(packageFile, “”).Install)); */ } catch (Exception ex) { //new ForceCloneAccept().RegisterEvent(true); //new SitemapFieldValues().RegisterEvent(true); //Sitecore.Configuration.Settings.Indexing.Enabled = true; ret.Message = "ERROR: " + ex.Message + "<br>" + installLog; ret.StackTrace = ex.StackTrace; ret.Successful = false; return(ret); } //Sitecore.Configuration.Settings.Indexing.Enabled = true; ret.Message = "SUCCESS"; ret.Successful = true; return(ret); //new ForceCloneAccept().RegisterEvent(true); //new SitemapFieldValues().RegisterEvent(true); }
/// <summary> /// Starts up a new tokenkeeper that will be set up as a singleton /// </summary> /// <param name="args"></param> public void Process(PipelineArgs args) { if (TokenKeeper.TokenSingleton == null) { RegisterSitecoreTokens(); TokenKeeper.TokenSingleton = Tokens; } Assert.ArgumentNotNull(args, "args"); RegisterRoutes("tokenManager"); if (RequiredSitecoreItemsMissing()) { var filepath = ""; if (System.Text.RegularExpressions.Regex.IsMatch(Settings.DataFolder, @"^(([a-zA-Z]:\\)|(//)).*")) //if we have an absolute path, rather than relative to the site root filepath = Settings.DataFolder + @"\packages\TokenManager.TokenManagerPackage.zip"; else filepath = HttpRuntime.AppDomainAppPath + Settings.DataFolder.Substring(1) + @"\packages\TokenManager.TokenManagerPackage.zip"; try { var manifestResourceStream = GetType().Assembly .GetManifestResourceStream("TokenManager.Resources.TokenManagerPackage.zip"); manifestResourceStream?.CopyTo(new FileStream(filepath, FileMode.Create)); Task.Run(() => { while (true) { if (!IsFileLocked(new FileInfo(filepath))) { using (new SecurityDisabler()) { using (new ProxyDisabler()) { using (new SyncOperationContext()) { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents events = new DefaultItemInstallerEvents( new BehaviourOptions(InstallMode.Overwrite, MergeMode.Undefined)); context.AddAspect(events); IFileInstallerEvents events1 = new DefaultFileInstallerEvents(true); context.AddAspect(events1); Sitecore.Install.Installer installer = new Sitecore.Install.Installer(); installer.InstallPackage(MainUtil.MapPath(filepath), context); break; } } } } else Thread.Sleep(1000); } }); } catch (Exception e) { Log.Error("TokenManager was unable to initialize", e, this); } } }
private void InstallSitecorePackage([NotNull] string fileName) { Context.SetActiveSite("shell"); using (new SecurityDisabler()) { using (new ProxyDisabler()) { using (new SyncOperationContext()) { var context = new SimpleProcessingContext(); var defaultItemInstallerEvents = new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode.Overwrite, MergeMode.Clear)); context.AddAspect(defaultItemInstallerEvents); var defaultFileInstallerEvents = new DefaultFileInstallerEvents(true); context.AddAspect(defaultFileInstallerEvents); var installer = new Installer(); installer.InstallPackage(FileUtil.MapPath(fileName), context); var packageReader = new PackageReader(FileUtil.MapPath(fileName)); var previewContext = Installer.CreatePreviewContext(); var view = new MetadataView(previewContext); var sink = new MetadataSink(view); sink.Initialize(previewContext); packageReader.Populate(sink); installer.ExecutePostStep(view.PostStep, previewContext); } } } }
/// <summary> /// Starts up a new tokenkeeper that will be set up as a singleton /// </summary> /// <param name="args"></param> public void Process(PipelineArgs args) { if (TokenIdentifier.Current == null) { TokenIdentifier.IdentifierSingleton = Identifier; } if (TokenKeeper.TokenSingleton == null) { TokenKeeper.TokenSingleton = Tokens; } Assert.ArgumentNotNull(args, "args"); RegisterRoutes("tokenManager"); TokenKeeper._isSc8 = IsSc8(); if (RequiredSitecoreItemsMissing()) { var filepath = ""; if (System.Text.RegularExpressions.Regex.IsMatch(Settings.DataFolder, @"^(([a-zA-Z]:\\)|(//)).*")) { //if we have an absolute path, rather than relative to the site root filepath = Settings.DataFolder + @"\packages\TokenManager.TokenManagerPackage.zip"; } else { filepath = HttpRuntime.AppDomainAppPath + Settings.DataFolder.Substring(1) + @"\packages\TokenManager.TokenManagerPackage.zip"; } try { using (var manifestResourceStream = GetType().Assembly .GetManifestResourceStream(TokenKeeper.IsSc8 ? "TokenManager.Resources.TokenManagerPackage.zip" : "TokenManager.Resources.TokenManagerSc7.zip")) using (var file = new FileStream(filepath, FileMode.Create)) { manifestResourceStream?.CopyTo(file); } int count = 0; while (true) { if (!IsFileLocked(new FileInfo(filepath))) { using (new SecurityDisabler()) using (new SyncOperationContext()) { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents events = new DefaultItemInstallerEvents( new BehaviourOptions(InstallMode.Overwrite, MergeMode.Undefined)); context.AddAspect(events); IFileInstallerEvents events1 = new DefaultFileInstallerEvents(true); context.AddAspect(events1); Sitecore.Install.Installer installer = new Sitecore.Install.Installer(); installer.InstallPackage(MainUtil.MapPath(filepath), context); break; } } Thread.Sleep(1000); count++; if (count > 15) { break; } } RegisterSitecoreTokens(); ValidateInsertOptions(); } catch (Exception e) { Log.Error("TokenManager was unable to initialize", e, this); } } else { RegisterSitecoreTokens(); ValidateInsertOptions(); } }
private void InstallPackage(FileInfo file) { // in case file disappeared since retrieved file.Refresh(); if (!file.Exists) { return; } var filenameWithoutExtension = Path.GetFileNameWithoutExtension(file.Name); filenameWithoutExtension = ItemUtil.ProposeValidItemName(filenameWithoutExtension); Assert.IsTrue(!string.IsNullOrWhiteSpace(filenameWithoutExtension), "The package should be renamed to something that item can have name of: " + file.Name); using (new SecurityDisabler()) { var db = Factory.GetDatabase("core"); var historyItem = db.GetItem("/sitecore/system/Packages/Installation history"); if (historyItem.Children.Any(x => string.Equals(x.Name, filenameWithoutExtension, StringComparison.OrdinalIgnoreCase))) { FridayLog.Info(AutoPackages.FeatureName, $"Install auto package skipped (already installed): \"{file.FullName}\""); return; } } // The way how SC creates history item it cumbersome - it has some non-obvious length limitations // so add extra logic to work around it. var historyFile = new FileInfo(file.FullName + ".history.txt"); if (historyFile.Exists) { FridayLog.Info(AutoPackages.FeatureName, $"Install auto package skipped (already installed): \"{file.FullName}\""); return; } File.AppendAllText(historyFile.FullName, DateTime.UtcNow.ToString("o") + "\r\n"); FridayLog.Info(AutoPackages.FeatureName, $"Install auto package (Skip on conflicts): \"{file.FullName}\""); using (new SecurityDisabler()) { var context = new SimpleProcessingContext(); // IItemInstallerEvents type cast is essential var items = (IItemInstallerEvents) new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode.Overwrite, MergeMode.Undefined)); context.AddAspect(items); // IFileInstallerEvents type cast is essential var files = (IFileInstallerEvents) new DefaultFileInstallerEvents(true); context.AddAspect(files); new Installer().InstallPackage(file.FullName, context); new Installer().InstallSecurity(file.FullName, context); var previewContext = Installer.CreatePreviewContext(); var packageReader = new PackageReader(file.FullName); var view = new MetadataView(previewContext); var metadataSink = new MetadataSink(view); metadataSink.Initialize(previewContext); packageReader.Populate(metadataSink); new Installer().ExecutePostStep(view.PostStep, previewContext); } }
private bool EnsureItemDependencies(Type type) { if (RequiredItemMissing()) { var filepath = ""; //if we have an absolute path, rather than relative to the site root if (System.Text.RegularExpressions.Regex.IsMatch(Settings.DataFolder, @"^(([a-zA-Z]:\\)|(//)).*")) { filepath = Settings.DataFolder + @"\packages\ThisIsMyPackage.zip"; } else { filepath = State.HttpRuntime.AppDomainAppPath + Settings.DataFolder.Substring(1) + @"\packages\ThisIsMyPackage.zip"; } try { type.Assembly .GetManifestResourceStream($"{type.Assembly.GetName()}.ThisIsMyPackage.zip") ?.CopyTo(new FileStream(filepath, FileMode.Create)); Task.Run(() => { while (true) { if (!IsFileLocked(new FileInfo(filepath))) { using (new SecurityDisabler()) { using (new SyncOperationContext()) { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents events = new DefaultItemInstallerEvents( new BehaviourOptions(InstallMode.Overwrite, MergeMode.Undefined)); context.AddAspect(events); IFileInstallerEvents events1 = new DefaultFileInstallerEvents(true); context.AddAspect(events1); Sitecore.Install.Installer installer = new Sitecore.Install.Installer(); installer.InstallPackage(MainUtil.MapPath(filepath), context); break; } } } Thread.Sleep(1000); } }); } catch (Exception e) { Log.Error("Unable to install dependent package", e, this); return(false); } return(true); } return(true); }
protected override void ProcessRecord() { var fileName = Path; PerformInstallAction(() => { if (!System.IO.Path.IsPathRooted(fileName)) { var packagePath = FullPackagePath(fileName); WriteVerbose($"Path is not rooted. Updating to {packagePath}."); if (!FileUtil.Exists(packagePath)) { packagePath = System.IO.Path.GetFullPath( System.IO.Path.Combine( CurrentProviderLocation("FileSystem").ProviderPath, fileName)); WriteVerbose($"Path could not be found. Updating to {packagePath}."); if (!FileUtil.Exists(packagePath)) { WriteVerbose("Path still could not be found. Check that the file actually exists in the Sitecore package directory."); } } fileName = packagePath; } if (ShouldProcess(fileName, "Install package")) { var obsoleter = TypeResolver.Resolve <IObsoleter>(); var indexSetting = obsoleter.IndexingEnabled; if (DisableIndexing.IsPresent) { obsoleter.IndexingEnabled = false; } try { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents instance1 = new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode, MergeMode)); context.AddAspect(instance1); IFileInstallerEvents instance2 = new DefaultFileInstallerEvents(true); context.AddAspect(instance2); var installer = new Installer(); installer.InstallPackage(fileName, context); ISource <PackageEntry> source = new PackageReader(fileName); var previewContext = Installer.CreatePreviewContext(); var view = new MetadataView(previewContext); var metadataSink = new MetadataSink(view); metadataSink.Initialize(previewContext); source.Populate(metadataSink); installer.ExecutePostStep(view.PostStep, previewContext); } finally { if (DisableIndexing.IsPresent) { obsoleter.IndexingEnabled = indexSetting; } } } }); }
protected override void ProcessRecord() { var fileName = Path; PerformInstallAction(() => { if (!System.IO.Path.IsPathRooted(fileName)) { var packagePath = FullPackagePath(fileName); WriteVerbose($"Path is not rooted. Updating to {packagePath}."); if (!FileUtil.Exists(packagePath)) { packagePath = System.IO.Path.GetFullPath( System.IO.Path.Combine( CurrentProviderLocation("FileSystem").ProviderPath, fileName)); WriteVerbose($"Path could not be found. Updating to {packagePath}."); if (!FileUtil.Exists(packagePath)) { WriteVerbose("Path still could not be found. Check that the file actually exists in the Sitecore package directory."); } } fileName = packagePath; } if (ShouldProcess(fileName, "Install package")) { var indexSetting = Sitecore.Configuration.Settings.Indexing.Enabled; if (DisableIndexing.IsPresent) { Sitecore.Configuration.Settings.Indexing.Enabled = false; } try { IProcessingContext context = new SimpleProcessingContext(); IItemInstallerEvents instance1 = new DefaultItemInstallerEvents(new BehaviourOptions(InstallMode, MergeMode)); context.AddAspect(instance1); IFileInstallerEvents instance2 = new DefaultFileInstallerEvents(true); context.AddAspect(instance2); var installer = new Installer(); installer.InstallPackage(fileName, context); ISource<PackageEntry> source = new PackageReader(fileName); var previewContext = Installer.CreatePreviewContext(); var view = new MetadataView(previewContext); var metadataSink = new MetadataSink(view); metadataSink.Initialize(previewContext); source.Populate(metadataSink); installer.ExecutePostStep(view.PostStep, previewContext); } finally { if (DisableIndexing.IsPresent) { Sitecore.Configuration.Settings.Indexing.Enabled = indexSetting; } } } }); }