GetAdvertisingManifestVersionAndWorkloads(ManifestId manifestId) { var manifestPath = Path.Combine(GetAdvertisingManifestPath(_sdkFeatureBand, manifestId), "WorkloadManifest.json"); if (!File.Exists(manifestPath)) { return(null); } using (FileStream fsSource = new FileStream(manifestPath, FileMode.Open, FileAccess.Read)) { var manifest = WorkloadManifestReader.ReadWorkloadManifest(manifestId.ToString(), fsSource, manifestPath); // we need to know the feature band of the advertised manifest (read it from the AdvertisedManifestFeatureBand.txt file) // if we don't find the file then use the current feature band var adManifestFeatureBandPath = Path.Combine(GetAdvertisingManifestPath(_sdkFeatureBand, manifestId), "AdvertisedManifestFeatureBand.txt"); SdkFeatureBand adManifestFeatureBand = _sdkFeatureBand; if (File.Exists(adManifestFeatureBandPath)) { adManifestFeatureBand = new SdkFeatureBand(File.ReadAllText(adManifestFeatureBandPath)); } return(new ManifestVersion(manifest.Version), adManifestFeatureBand, manifest.Workloads.Values.OfType <WorkloadDefinition>().ToDictionary(w => w.Id)); } }
private async Task UpdateAdvertisingManifestAsync(ManifestId manifestId, bool includePreviews) { string packagePath = null; string extractionPath = null; try { var adManifestPath = GetAdvertisingManifestPath(_sdkFeatureBand, manifestId); try { packagePath = await _nugetPackageDownloader.DownloadPackageAsync(GetManifestPackageId(_sdkFeatureBand, manifestId), includePreview : includePreviews); } catch (NuGetPackageNotFoundException) { _reporter.WriteLine(string.Format(LocalizableStrings.AdManifestPackageDoesNotExist, manifestId)); } extractionPath = Path.Combine(_userHome, ".dotnet", "sdk-advertising-temp", $"{manifestId}-extracted"); Directory.CreateDirectory(extractionPath); var resultingFiles = await _nugetPackageDownloader.ExtractPackageAsync(packagePath, new DirectoryPath(extractionPath)); if (Directory.Exists(adManifestPath)) { Directory.Delete(adManifestPath, true); } Directory.CreateDirectory(Path.GetDirectoryName(adManifestPath)); FileAccessRetrier.RetryOnMoveAccessFailure(() => Directory.Move(Path.Combine(extractionPath, "data"), adManifestPath)); _reporter.WriteLine(string.Format(LocalizableStrings.AdManifestUpdated, manifestId)); } catch (Exception e) { _reporter.WriteLine(string.Format(LocalizableStrings.FailedAdManifestUpdate, manifestId, e.Message)); } finally { if (!string.IsNullOrEmpty(extractionPath) && Directory.Exists(extractionPath)) { Directory.Delete(extractionPath, true); } if (!string.IsNullOrEmpty(packagePath) && File.Exists(packagePath)) { File.Delete(packagePath); } var versionDir = Path.GetDirectoryName(packagePath); if (Directory.Exists(versionDir) && !Directory.GetFileSystemEntries(versionDir).Any()) { Directory.Delete(versionDir); var idDir = Path.GetDirectoryName(versionDir); if (Directory.Exists(idDir) && !Directory.GetFileSystemEntries(idDir).Any()) { Directory.Delete(idDir); } } } }
private ManifestVersion GetInstalledManifestVersion(ManifestId manifestId) { var manifest = _workloadResolver.GetInstalledManifests() .FirstOrDefault(manifest => manifest.Id.ToLowerInvariant().Equals(manifestId.ToString())); if (manifest == null) { throw new Exception(string.Format(LocalizableStrings.ManifestDoesNotExist, manifestId.ToString())); } return(new ManifestVersion(manifest.Version)); }
private string GetOfflinePackagePath(SdkFeatureBand sdkFeatureBand, ManifestId manifestId, DirectoryPath?offlineCache = null) { string packagePath = Directory.GetFiles(offlineCache.Value.Value) .Where(path => path.EndsWith(".nupkg")) .Where(path => { var manifestPackageId = GetManifestPackageId(sdkFeatureBand, manifestId).ToString(); return(Path.GetFileName(path).StartsWith(manifestPackageId, StringComparison.OrdinalIgnoreCase)); }) .Max(); return(packagePath); }
private async Task <bool> NewerManifestPackageExists(ManifestId manifest) { try { var currentVersion = NuGetVersion.Parse(_workloadResolver.GetManifestVersion(manifest.ToString())); var latestVersion = await _nugetPackageDownloader.GetLatestPackageVerion(GetManifestPackageId(_sdkFeatureBand, manifest)); return(latestVersion > currentVersion); } catch (Exception) { return(false); } }
private ManifestVersion GetAdvertisingManifestVersion(ManifestId manifestId) { var manifestPath = Path.Combine(GetAdvertisingManifestPath(_sdkFeatureBand, manifestId), "WorkloadManifest.json"); if (!File.Exists(manifestPath)) { return(null); } using (FileStream fsSource = new FileStream(manifestPath, FileMode.Open, FileAccess.Read)) { var manifest = WorkloadManifestReader.ReadWorkloadManifest(manifestId.ToString(), fsSource); return(new ManifestVersion(manifest.Version)); } }
GetAdvertisingManifestVersionAndWorkloads(ManifestId manifestId) { var manifestPath = Path.Combine(GetAdvertisingManifestPath(_sdkFeatureBand, manifestId), "WorkloadManifest.json"); if (!File.Exists(manifestPath)) { return(null); } using (FileStream fsSource = new FileStream(manifestPath, FileMode.Open, FileAccess.Read)) { var manifest = WorkloadManifestReader.ReadWorkloadManifest(manifestId.ToString(), fsSource); return(new ManifestVersion(manifest.Version), manifest.Workloads.Values.OfType <WorkloadDefinition>().ToDictionary(w => w.Id)); } }
public void InstallWorkloadManifest(ManifestId manifestId, ManifestVersion manifestVersion, SdkFeatureBand sdkFeatureBand, DirectoryPath?offlineCache = null) { try { Log?.LogMessage($"Installing manifest, {nameof(manifestId)}: {manifestId}, {nameof(manifestVersion)}: {manifestVersion}, {nameof(sdkFeatureBand)}: {sdkFeatureBand}"); // Resolve the package ID for the manifest payload package string msiPackageId = WorkloadManifestUpdater.GetManifestPackageId(sdkFeatureBand, manifestId).ToString(); string msiPackageVersion = $"{manifestVersion}"; Log?.LogMessage($"Resolving {manifestId} ({manifestVersion}) to {msiPackageId}.{msiPackageVersion}."); // Retrieve the payload from the MSI package cache. MsiPayload msiPayload = GetCachedMsiPayload(msiPackageId, msiPackageVersion); VerifyPackage(msiPayload); } catch (Exception e) { LogException(e); throw; } }
private ManifestVersion GetInstalledManifestVersion(ManifestId manifestId) { var manifestDir = _workloadManifestProvider.GetManifestDirectories() .FirstOrDefault(dir => Path.GetFileName(dir).ToLowerInvariant().Equals(manifestId.ToString())); if (manifestDir == null) { throw new Exception(string.Format(LocalizableStrings.ManifestDoesNotExist, manifestId.ToString())); } var manifestPath = Path.Combine(manifestDir, "WorkloadManifest.json"); if (!File.Exists(manifestPath)) { throw new Exception(string.Format(LocalizableStrings.ManifestDoesNotExist, manifestId.ToString())); } using (FileStream fsSource = new FileStream(manifestPath, FileMode.Open, FileAccess.Read)) { var manifest = WorkloadManifestReader.ReadWorkloadManifest(manifestId.ToString(), fsSource); return(new ManifestVersion(manifest.Version)); } }
internal static PackageId GetManifestPackageId(SdkFeatureBand featureBand, ManifestId manifestId) => GetManifestPackageId(featureBand, manifestId, InstallType.FileBased);
public void InstallWorkloadManifest(ManifestId manifestId, ManifestVersion manifestVersion, SdkFeatureBand sdkFeatureBand, DirectoryPath?offlineCache = null, bool isRollback = false) { string packagePath = null; string tempExtractionDir = null; string tempBackupDir = null; string rootInstallDir = WorkloadFileBasedInstall.IsUserLocal(_dotnetDir, sdkFeatureBand.ToString()) ? _userProfileDir : _dotnetDir; var manifestPath = Path.Combine(rootInstallDir, "sdk-manifests", sdkFeatureBand.ToString(), manifestId.ToString()); _reporter.WriteLine(string.Format(LocalizableStrings.InstallingWorkloadManifest, manifestId, manifestVersion)); try { TransactionalAction.Run( action: () => { if (offlineCache == null || !offlineCache.HasValue) { packagePath = _nugetPackageDownloader.DownloadPackageAsync(WorkloadManifestUpdater.GetManifestPackageId(sdkFeatureBand, manifestId), new NuGetVersion(manifestVersion.ToString()), _packageSourceLocation).GetAwaiter().GetResult(); } else { packagePath = Path.Combine(offlineCache.Value.Value, $"{WorkloadManifestUpdater.GetManifestPackageId(sdkFeatureBand, manifestId)}.{manifestVersion}.nupkg"); if (!File.Exists(packagePath)) { throw new Exception(string.Format(LocalizableStrings.CacheMissingPackage, WorkloadManifestUpdater.GetManifestPackageId(sdkFeatureBand, manifestId), manifestVersion, offlineCache)); } } tempExtractionDir = Path.Combine(_tempPackagesDir.Value, $"{manifestId}-{manifestVersion}-extracted"); Directory.CreateDirectory(tempExtractionDir); var manifestFiles = _nugetPackageDownloader.ExtractPackageAsync(packagePath, new DirectoryPath(tempExtractionDir)).GetAwaiter().GetResult(); if (Directory.Exists(manifestPath) && Directory.GetFileSystemEntries(manifestPath).Any()) { // Backup existing manifest data for roll back purposes tempBackupDir = Path.Combine(_tempPackagesDir.Value, $"{manifestId}-{manifestVersion}-backup"); if (Directory.Exists(tempBackupDir)) { Directory.Delete(tempBackupDir, true); } FileAccessRetrier.RetryOnMoveAccessFailure(() => DirectoryPath.MoveDirectory(manifestPath, tempBackupDir)); } Directory.CreateDirectory(Path.GetDirectoryName(manifestPath)); FileAccessRetrier.RetryOnMoveAccessFailure(() => DirectoryPath.MoveDirectory(Path.Combine(tempExtractionDir, "data"), manifestPath)); }, rollback: () => { if (!string.IsNullOrEmpty(tempBackupDir) && Directory.Exists(tempBackupDir)) { FileAccessRetrier.RetryOnMoveAccessFailure(() => DirectoryPath.MoveDirectory(tempBackupDir, manifestPath)); } }); // Delete leftover dirs and files if (!string.IsNullOrEmpty(packagePath) && File.Exists(packagePath) && (offlineCache == null || !offlineCache.HasValue)) { File.Delete(packagePath); } var versionDir = Path.GetDirectoryName(packagePath); if (Directory.Exists(versionDir) && !Directory.GetFileSystemEntries(versionDir).Any()) { Directory.Delete(versionDir); var idDir = Path.GetDirectoryName(versionDir); if (Directory.Exists(idDir) && !Directory.GetFileSystemEntries(idDir).Any()) { Directory.Delete(idDir); } } if (!string.IsNullOrEmpty(tempExtractionDir) && Directory.Exists(tempExtractionDir)) { Directory.Delete(tempExtractionDir, true); } if (!string.IsNullOrEmpty(tempBackupDir) && Directory.Exists(tempBackupDir)) { Directory.Delete(tempBackupDir, true); } } catch (Exception e) { throw new Exception(string.Format(LocalizableStrings.FailedToInstallWorkloadManifest, manifestId, manifestVersion, e.Message)); } }
public void InstallWorkloadManifest(ManifestId manifestId, ManifestVersion manifestVersion, SdkFeatureBand sdkFeatureBand, DirectoryPath?offlineCache = null, bool isRollback = false) { try { ReportPendingReboot(); // Rolling back a manifest update after a successful install is essentially a downgrade, which is blocked so we have to // treat it as a special case and is different from the install failing and rolling that back, though depending where the install // failed, it may have removed the old product already. Log?.LogMessage($"Installing manifest: Id: {manifestId}, version: {manifestVersion}, feature band: {sdkFeatureBand}, rollback: {isRollback}."); // Resolve the package ID for the manifest payload package string msiPackageId = WorkloadManifestUpdater.GetManifestPackageId(sdkFeatureBand, manifestId, InstallType.Msi).ToString(); string msiPackageVersion = $"{manifestVersion}"; Log?.LogMessage($"Resolving {manifestId} ({manifestVersion}) to {msiPackageId} ({msiPackageVersion})."); // Retrieve the payload from the MSI package cache. MsiPayload msi = GetCachedMsiPayload(msiPackageId, msiPackageVersion, offlineCache); VerifyPackage(msi); DetectState state = DetectPackage(msi.ProductCode, out Version installedVersion); InstallAction plannedAction = PlanPackage(msi, state, InstallAction.Install, installedVersion, out IEnumerable <string> relatedProducts); // If we've detected a downgrade, it's possible we might be doing a rollback after the manifests were updated, // but another error occurred. In this case we need to try and uninstall the upgrade and then install the lower // version of the MSI. The downgrade can also be a deliberate rollback. if (plannedAction == InstallAction.Downgrade && isRollback && state == DetectState.Absent) { Log?.LogMessage($"Rolling back manifest update."); // The provider keys for manifest packages are stable across feature bands so we retain dependents during upgrades. DependencyProvider depProvider = new DependencyProvider(msi.Manifest.ProviderKeyName); // Try and remove the SDK dependency, but ignore any remaining dependencies since // we want to force the removal of the old version. The remaining dependencies and the provider // key won't be removed. UpdateDependent(InstallRequestType.RemoveDependent, msi.Manifest.ProviderKeyName, _dependent); // Since we don't have records for manifests, we need to try and retrieve the ProductCode of // the newer MSI that's installed that we want to remove using its dependency provider. string productCode = depProvider.ProductCode; if (string.IsNullOrWhiteSpace(productCode)) { // We don't know the MSI package that wrote this provider key, so if the ProductCode is missing // we can't do anything else. Log?.LogMessage($"Failed to retrieve the ProductCode for provider: {depProvider.ProviderKeyName}."); return; } Log?.LogMessage($"Found ProductCode {productCode} registered against provider, {depProvider.ProviderKeyName}."); // This is a best effort. If for some reason the manifest installers were fixed, for example, manually // adding additional upgrade paths to work around previous faulty authoring, we may have multiple related // products. The best we can do is to check for at least one match and remove it and then try the rollback. if (!relatedProducts.Contains(productCode, StringComparer.OrdinalIgnoreCase)) { Log?.LogMessage($"Cannot rollback manifest. ProductCode does not match any detected related products."); return; } string logFile = GetMsiLogName(productCode, InstallAction.Uninstall); uint error = UninstallMsi(productCode, logFile, ignoreDependencies: true); ExitOnError(error, "Failed to uninstall manifest package."); // Detect the package again and fall through to the original execution. If that fails, then there's nothing // we could have done. Log?.LogMessage("Replanning manifest package."); state = DetectPackage(msi, out Version _); plannedAction = PlanPackage(msi, state, InstallAction.Install, installedVersion, out IEnumerable <string> _); } ExecutePackage(msi, plannedAction); // Update the reference count against the MSI. UpdateDependent(InstallRequestType.AddDependent, msi.Manifest.ProviderKeyName, _dependent); } catch (Exception e) { LogException(e); throw; } }
//internal static PackageId GetManifestPackageId(SdkFeatureBand featureBand, ManifestId manifestId) => // new PackageId($"{manifestId}.Manifest-{featureBand}"); internal static PackageId GetManifestPackageId(SdkFeatureBand featureBand, ManifestId manifestId) => WorkloadInstallerFactory.GetWorkloadInstallType(featureBand, Path.GetDirectoryName(Environment.ProcessPath)) switch {
private string GetAdvertisingManifestPath(SdkFeatureBand featureBand, ManifestId manifestId) => Path.Combine(_userHome, ".dotnet", "sdk-advertising", featureBand.ToString(), manifestId.ToString());
private async Task UpdateAdvertisingManifestAsync(WorkloadManifestInfo manifest, bool includePreviews, DirectoryPath?offlineCache = null) { string packagePath = null; string extractionPath = null; var manifestId = new ManifestId(manifest.Id); string currentFeatureBand = _sdkFeatureBand.ToString(); try { var adManifestPath = GetAdvertisingManifestPath(_sdkFeatureBand, manifestId); bool success; (success, packagePath) = await GetManifestPackageUpdate(_sdkFeatureBand, manifestId, includePreviews, offlineCache); if (!success) { if (!(manifest.ManifestFeatureBand).Equals(_sdkFeatureBand)) { (success, packagePath) = await GetManifestPackageUpdate(new SdkFeatureBand(manifest.ManifestFeatureBand), manifestId, includePreviews, offlineCache); currentFeatureBand = manifest.ManifestFeatureBand.ToString(); } } if (!success) { _reporter.WriteLine(string.Format(LocalizableStrings.AdManifestPackageDoesNotExist, manifestId)); return; } extractionPath = Path.Combine(_tempDirPath, "dotnet-sdk-advertising-temp", $"{manifestId}-extracted"); Directory.CreateDirectory(extractionPath); var resultingFiles = await _nugetPackageDownloader.ExtractPackageAsync(packagePath, new DirectoryPath(extractionPath)); if (Directory.Exists(adManifestPath)) { Directory.Delete(adManifestPath, true); } Directory.CreateDirectory(Path.GetDirectoryName(adManifestPath)); FileAccessRetrier.RetryOnMoveAccessFailure(() => DirectoryPath.MoveDirectory(Path.Combine(extractionPath, "data"), adManifestPath)); // add file that contains the advertisted manifest feature band so GetAdvertisingManifestVersionAndWorkloads will use correct feature band, regardless of if rollback occurred or not File.WriteAllText(Path.Combine(adManifestPath, "AdvertisedManifestFeatureBand.txt"), currentFeatureBand); if (_displayManifestUpdates) { _reporter.WriteLine(string.Format(LocalizableStrings.AdManifestUpdated, manifestId)); } } catch (Exception e) { _reporter.WriteLine(string.Format(LocalizableStrings.FailedAdManifestUpdate, manifestId, e.Message)); } finally { if (!string.IsNullOrEmpty(extractionPath) && Directory.Exists(extractionPath)) { Directory.Delete(extractionPath, true); } if (!string.IsNullOrEmpty(packagePath) && File.Exists(packagePath) && (offlineCache == null || !offlineCache.HasValue)) { File.Delete(packagePath); } if (!string.IsNullOrEmpty(packagePath) && (offlineCache == null || !offlineCache.HasValue)) { var versionDir = Path.GetDirectoryName(packagePath); if (Directory.Exists(versionDir) && !Directory.GetFileSystemEntries(versionDir).Any()) { Directory.Delete(versionDir); var idDir = Path.GetDirectoryName(versionDir); if (Directory.Exists(idDir) && !Directory.GetFileSystemEntries(idDir).Any()) { Directory.Delete(idDir); } } } } }
private async Task UpdateAdvertisingManifestAsync(ManifestId manifestId, bool includePreviews, DirectoryPath?offlineCache = null) { string packagePath = null; string extractionPath = null; try { var adManifestPath = GetAdvertisingManifestPath(_sdkFeatureBand, manifestId); if (offlineCache == null || !offlineCache.HasValue) { try { packagePath = await _nugetPackageDownloader.DownloadPackageAsync( GetManifestPackageId(_sdkFeatureBand, manifestId), packageSourceLocation : _packageSourceLocation, includePreview : includePreviews); } catch (NuGetPackageNotFoundException) { _reporter.WriteLine(string.Format(LocalizableStrings.AdManifestPackageDoesNotExist, manifestId)); } } else { packagePath = Directory.GetFiles(offlineCache.Value.Value) .Where(path => path.EndsWith(".nupkg")) .Where(path => Path.GetFileName(path).StartsWith(GetManifestPackageId(_sdkFeatureBand, manifestId).ToString())) .Max(); if (!File.Exists(packagePath)) { throw new Exception(string.Format(LocalizableStrings.CacheMissingPackage, GetManifestPackageId(_sdkFeatureBand, manifestId), "*", offlineCache)); } } extractionPath = Path.Combine(_tempDirPath, "dotnet-sdk-advertising-temp", $"{manifestId}-extracted"); Directory.CreateDirectory(extractionPath); var resultingFiles = await _nugetPackageDownloader.ExtractPackageAsync(packagePath, new DirectoryPath(extractionPath)); if (Directory.Exists(adManifestPath)) { Directory.Delete(adManifestPath, true); } Directory.CreateDirectory(Path.GetDirectoryName(adManifestPath)); FileAccessRetrier.RetryOnMoveAccessFailure(() => DirectoryPath.MoveDirectory(Path.Combine(extractionPath, "data"), adManifestPath)); _reporter.WriteLine(string.Format(LocalizableStrings.AdManifestUpdated, manifestId)); } catch (Exception e) { _reporter.WriteLine(string.Format(LocalizableStrings.FailedAdManifestUpdate, manifestId, e.Message)); } finally { if (!string.IsNullOrEmpty(extractionPath) && Directory.Exists(extractionPath)) { Directory.Delete(extractionPath, true); } if (!string.IsNullOrEmpty(packagePath) && File.Exists(packagePath) && (offlineCache == null || !offlineCache.HasValue)) { File.Delete(packagePath); } var versionDir = Path.GetDirectoryName(packagePath); if (Directory.Exists(versionDir) && !Directory.GetFileSystemEntries(versionDir).Any()) { Directory.Delete(versionDir); var idDir = Path.GetDirectoryName(versionDir); if (Directory.Exists(idDir) && !Directory.GetFileSystemEntries(idDir).Any()) { Directory.Delete(idDir); } } } }
private async Task <String> GetOnlinePackagePath(SdkFeatureBand sdkFeatureBand, ManifestId manifestId, bool includePreviews) { string packagePath = await _nugetPackageDownloader.DownloadPackageAsync( GetManifestPackageId(sdkFeatureBand, manifestId), packageSourceLocation : _packageSourceLocation, includePreview : includePreviews); return(packagePath); }
internal static PackageId GetManifestPackageId(SdkFeatureBand featureBand, ManifestId manifestId, InstallType installType) => installType switch {
public void InstallWorkloadManifest(ManifestId manifestId, ManifestVersion manifestVersion, SdkFeatureBand sdkFeatureBand, DirectoryPath?offlineCache = null) => throw new NotImplementedException();
public void InstallWorkloadManifest(ManifestId manifestId, ManifestVersion manifestVersion, SdkFeatureBand sdkFeatureBand) { string packagePath = null; string tempExtractionDir = null; string tempBackupDir = null; var manifestPath = Path.Combine(_dotnetDir, "sdk-manifests", sdkFeatureBand.ToString(), manifestId.ToString()); _reporter.WriteLine(string.Format(LocalizableStrings.InstallingWorkloadManifest, manifestId, manifestVersion)); try { TransactionalAction.Run( action: () => { packagePath = _nugetPackageDownloader.DownloadPackageAsync(WorkloadManifestUpdater.GetManifestPackageId(sdkFeatureBand, manifestId), new NuGetVersion(manifestVersion.ToString())).Result; tempExtractionDir = Path.Combine(_tempPackagesDir.Value, $"{manifestId}-{manifestVersion}-extracted"); Directory.CreateDirectory(tempExtractionDir); var manifestFiles = _nugetPackageDownloader.ExtractPackageAsync(packagePath, new DirectoryPath(tempExtractionDir)).Result; if (Directory.Exists(manifestPath) && Directory.GetFileSystemEntries(manifestPath).Any()) { // Backup existing manifest data for roll back purposes tempBackupDir = Path.Combine(_tempPackagesDir.Value, $"{manifestId}-{manifestVersion}-backup"); if (Directory.Exists(tempBackupDir)) { Directory.Delete(tempBackupDir, true); } FileAccessRetrier.RetryOnMoveAccessFailure(() => Directory.Move(manifestPath, tempBackupDir)); } Directory.CreateDirectory(Path.GetDirectoryName(manifestPath)); FileAccessRetrier.RetryOnMoveAccessFailure(() => Directory.Move(Path.Combine(tempExtractionDir, "data"), manifestPath)); }, rollback: () => { if (!string.IsNullOrEmpty(tempBackupDir) && Directory.Exists(tempBackupDir)) { FileAccessRetrier.RetryOnMoveAccessFailure(() => Directory.Move(tempBackupDir, manifestPath)); } }); // Delete leftover dirs and files if (!string.IsNullOrEmpty(packagePath) && File.Exists(packagePath)) { File.Delete(packagePath); } var versionDir = Path.GetDirectoryName(packagePath); if (Directory.Exists(versionDir) && !Directory.GetFileSystemEntries(versionDir).Any()) { Directory.Delete(versionDir); var idDir = Path.GetDirectoryName(versionDir); if (Directory.Exists(idDir) && !Directory.GetFileSystemEntries(idDir).Any()) { Directory.Delete(idDir); } } if (!string.IsNullOrEmpty(tempExtractionDir) && Directory.Exists(tempExtractionDir)) { Directory.Delete(tempExtractionDir, true); } if (!string.IsNullOrEmpty(tempBackupDir) && Directory.Exists(tempBackupDir)) { Directory.Delete(tempBackupDir, true); } } catch (Exception e) { throw new Exception(string.Format(LocalizableStrings.FailedToInstallWorkloadManifest, manifestId, manifestVersion, e.Message)); } }
private string GetAdvertisingManifestPath(SdkFeatureBand featureBand, ManifestId manifestId) => Path.Combine(_userProfileDir, "sdk-advertising", featureBand.ToString(), manifestId.ToString());
private async Task <(bool, string)> GetManifestPackageUpdate(SdkFeatureBand sdkFeatureBand, ManifestId manifestId, bool includePreviews, DirectoryPath?offlineCache = null) { if (offlineCache == null || !offlineCache.HasValue) { try { string packagePath = await GetOnlinePackagePath(sdkFeatureBand, manifestId, includePreviews); return(true, packagePath); } catch (NuGetPackageNotFoundException) { return(false, null); } } else { string packagePath = GetOfflinePackagePath(sdkFeatureBand, manifestId, offlineCache); return(packagePath != null, packagePath); } }
public void InstallWorkloadManifest(ManifestId manifestId, ManifestVersion manifestVersion, SdkFeatureBand sdkFeatureBand) => throw new NotImplementedException();
internal static PackageId GetManifestPackageId(SdkFeatureBand featureBand, ManifestId manifestId) => new PackageId($"{manifestId}.Manifest-{featureBand}");