diff --git a/SitecorePackageDeployer/Tasks/InstallPackage.cs b/SitecorePackageDeployer/Tasks/InstallPackage.cs index 6989321..376cdd6 100644 --- a/SitecorePackageDeployer/Tasks/InstallPackage.cs +++ b/SitecorePackageDeployer/Tasks/InstallPackage.cs @@ -276,18 +276,25 @@ internal static void ExecutePostSteps(InstallLogger installLogger, PostStepDetai MetadataView metedateView = UpdateHelper.LoadMetadata(postStepDetails.PostStepPackageFilename); List logMessages = new List(); - //Execute the post install steps - DiffInstaller diffInstaller = new DiffInstaller(UpgradeAction.Upgrade); - diffInstaller.ExecutePostInstallationInstructions(postStepDetails.PostStepPackageFilename, postStepDetails.HistoryPath, InstallMode.Update, metedateView, installLogger, ref logMessages); - - //Move the update package into the history folder - File.Move(postStepDetails.PostStepPackageFilename, Path.Combine(postStepDetails.HistoryPath, Path.GetFileName(postStepDetails.PostStepPackageFilename))); + try + { + //Execute the post install steps + DiffInstaller diffInstaller = new DiffInstaller(UpgradeAction.Upgrade); + diffInstaller.ExecutePostInstallationInstructions(postStepDetails.PostStepPackageFilename, postStepDetails.HistoryPath, InstallMode.Update, metedateView, installLogger, ref logMessages); + } + finally + { + //Move the update package into the history folder + File.Move(postStepDetails.PostStepPackageFilename, Path.Combine(postStepDetails.HistoryPath, Path.GetFileName(postStepDetails.PostStepPackageFilename))); + } } catch (Exception ex) { Log.Fatal("Post step execution failed", ex, "InstallPackage"); installLogger.Fatal("Post step execution failed", ex); + + throw; } } @@ -345,18 +352,25 @@ private void FindAndUpdateChangedConfigs(string installPackageName) /// private void SaveInstallationMessages(string installationHistoryRoot, List logMessages) { - if (string.IsNullOrEmpty(installationHistoryRoot)) + try { - installationHistoryRoot = FileUtil.MakePath(FileUtils.InstallationHistoryRoot, "Upgrade_FAILURE_" + DateTime.Now.ToString("yyyyMMddTHHmmss") + DateTime.Now.Millisecond); - } + if (string.IsNullOrEmpty(installationHistoryRoot)) + { + installationHistoryRoot = FileUtil.MakePath(FileUtils.InstallationHistoryRoot, "Upgrade_FAILURE_" + DateTime.Now.ToString("yyyyMMddTHHmmss") + DateTime.Now.Millisecond); + } - string messagesFile = Path.Combine(installationHistoryRoot, "messages.xml"); - FileUtil.EnsureFolder(messagesFile); + string messagesFile = Path.Combine(installationHistoryRoot, "messages.xml"); + FileUtil.EnsureFolder(messagesFile); - using (FileStream fileStream = File.Create(messagesFile)) + using (FileStream fileStream = File.Create(messagesFile)) + { + XmlEntrySerializer xmlEntrySerializer = new XmlEntrySerializer(); + xmlEntrySerializer.Serialize(logMessages, fileStream); + } + } + catch(Exception ex) { - XmlEntrySerializer xmlEntrySerializer = new XmlEntrySerializer(); - xmlEntrySerializer.Serialize(logMessages, fileStream); + Log.Fatal("Error saving installation messages", ex, typeof(InstallPackage)); } } }