public void Upgrade(ILogger logger, IDeploymentComponentFactory deploymentComponentFactory, NugetPackage installedPackage) { PerformanceLogger performanceLogger = new PerformanceLogger(logger); performanceLogger.Restart("Opening, Calculating and planing deployment component"); using (ParallelReadableZipArchive upgradeZipArchive = Open(packagePathAndFileName)) { if (upgradeZipArchive == null) { throw new InvalidOperationException($"Source archive {packagePathAndFileName} not found."); } using (ParallelReadableZipArchive installedzipArchive = installedPackage?.Open()) { IReadOnlyCollection <ParallelReadableZipArchiveEntry> installedEntries = installedzipArchive?.Entries; IReadOnlyCollection <ParallelReadableZipArchiveEntry> newEntries = upgradeZipArchive.Entries; IReadOnlyCollection <IDeploymentComponent> deploymentComponents = deploymentComponentFactory.CreateDeploymentComponents(this, installedPackage, installedEntries, newEntries); performanceLogger.Stop(); performanceLogger.Restart("Execution of deployment activities"); UpgradeDeploymentComponents(deploymentComponents, newEntries); performanceLogger.Stop(); } } }
/* * In case of error during uprading return a modified nuget package * assume that that everything that should be removed is still there * in case of upgrade it might be harder because we can not be sure what happend before. * but the deployment action must handle this! */ public void Upgrade(string packageId, Version packageVersion, string packageDownloadUri) { var loggerstate = new LoggerState { { nameof(packageId), packageId }, { nameof(packageVersion), packageVersion }, { nameof(packageDownloadUri), packageDownloadUri }, }; logger.LogInformation("Upgrading package '{0}' to version '{1}'", packageId, packageVersion); using (logger.BeginScope(loggerstate)) { PerformanceLogger performanceLogger = new PerformanceLogger(logger); logger.LogInformation("Starting action on package xml list."); performanceLogger.Restart("Starting action on package xml list."); packageListRepository.StartActionOnPackage(packageId, packageVersion); performanceLogger.Stop(); logger.LogInformation("Installing new package."); performanceLogger.Restart("Installing new package."); NugetPackage upgradePackage = nugetPackageRepository.InstallPackage(packageId, packageVersion, packageDownloadUri); performanceLogger.Stop(); logger.LogInformation("Reading installed package."); performanceLogger.Restart("Reading installed package."); NugetPackage installedPackage = nugetPackageRepository.ReadInstalledPackage(packageId); logger.LogInformation("Installed Package: {0}", installedPackage?.PackageIdentifier); performanceLogger.Stop(); logger.LogInformation("Upgrading package."); performanceLogger.Restart("Upgrading package."); upgradePackage.Upgrade(logger, deploymentComponentFactory, installedPackage); performanceLogger.Stop(); logger.LogInformation("Archiving package."); performanceLogger.Restart("Archiving package."); nugetPackageRepository.ArchivePackage(packageId); performanceLogger.Stop(); logger.LogInformation("Ending action on package xml list."); performanceLogger.Restart("Ending action on package xml list."); packageListRepository.EndActionOnPackage(packageId, packageVersion); performanceLogger.Stop(); } }