diff --git a/src/Cli/dotnet/commands/InstallingWorkloadCommand.cs b/src/Cli/dotnet/commands/InstallingWorkloadCommand.cs index bfd2105e20ec..fe836666aee5 100644 --- a/src/Cli/dotnet/commands/InstallingWorkloadCommand.cs +++ b/src/Cli/dotnet/commands/InstallingWorkloadCommand.cs @@ -35,6 +35,7 @@ internal abstract class InstallingWorkloadCommand : WorkloadCommandBase protected readonly ReleaseVersion _targetSdkVersion; protected readonly string _fromRollbackDefinition; protected string _workloadSetVersion; + protected string _workloadSetVersionFromGlobalJson; protected readonly PackageSourceLocation _packageSourceLocation; protected readonly IWorkloadResolverFactory _workloadResolverFactory; protected IWorkloadResolver _workloadResolver; @@ -104,7 +105,15 @@ public static bool ShouldUseWorkloadSetMode(SdkFeatureBand sdkFeatureBand, strin return installStateContents.UseWorkloadSets ?? false; } - protected IEnumerable HandleWorkloadUpdateFromVersion(ITransactionContext context, DirectoryPath? offlineCache) + protected void ErrorIfGlobalJsonAndCommandLineMismatch(string globaljsonPath) + { + if (!string.IsNullOrWhiteSpace(_workloadSetVersionFromGlobalJson) && !string.IsNullOrWhiteSpace(_workloadSetVersion) && !_workloadSetVersion.Equals(_workloadSetVersionFromGlobalJson)) + { + throw new Exception(string.Format(Strings.CannotSpecifyVersionOnCommandLineAndInGlobalJson, globaljsonPath)); + } + } + + protected bool TryHandleWorkloadUpdateFromVersion(ITransactionContext context, DirectoryPath? offlineCache, out IEnumerable updates) { // Ensure workload set mode is set to 'workloadset' // Do not skip checking the mode first, as setting it triggers @@ -114,11 +123,11 @@ protected IEnumerable HandleWorkloadUpdateFromVersion(ITr _workloadInstaller.UpdateInstallMode(_sdkFeatureBand, true); } - _workloadManifestUpdater.DownloadWorkloadSet(_workloadSetVersion, offlineCache); - return InstallWorkloadSet(context); + _workloadManifestUpdater.DownloadWorkloadSet(_workloadSetVersionFromGlobalJson ?? _workloadSetVersion, offlineCache); + return TryInstallWorkloadSet(context, out updates); } - public IEnumerable InstallWorkloadSet(ITransactionContext context) + public bool TryInstallWorkloadSet(ITransactionContext context, out IEnumerable updates) { var advertisingPackagePath = Path.Combine(_userProfileDir, "sdk-advertising", _sdkFeatureBand.ToString(), "microsoft.net.workloads"); if (File.Exists(Path.Combine(advertisingPackagePath, Constants.workloadSetVersionFileName))) @@ -126,15 +135,24 @@ public IEnumerable InstallWorkloadSet(ITransactionContext // This file isn't created in tests. PrintWorkloadSetTransition(File.ReadAllText(Path.Combine(advertisingPackagePath, Constants.workloadSetVersionFileName))); } + else if (_workloadInstaller is FileBasedInstaller || _workloadInstaller is NetSdkMsiInstallerClient) + { + // No workload sets found + Reporter.WriteLine(Update.LocalizableStrings.NoWorkloadUpdateFound); + updates = null; + return false; + } + var workloadSetPath = _workloadInstaller.InstallWorkloadSet(context, advertisingPackagePath); var files = Directory.EnumerateFiles(workloadSetPath, "*.workloadset.json"); - return _workloadManifestUpdater.ParseRollbackDefinitionFiles(files); + updates = _workloadManifestUpdater.ParseRollbackDefinitionFiles(files); + return true; } private void PrintWorkloadSetTransition(string newVersion) { var currentVersion = _workloadResolver.GetWorkloadVersion(); - if (currentVersion == null) + if (currentVersion == null || !string.IsNullOrWhiteSpace(_workloadSetVersionFromGlobalJson)) { Reporter.WriteLine(string.Format(Strings.NewWorkloadSet, newVersion)); } diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/FileBasedInstaller.cs b/src/Cli/dotnet/commands/dotnet-workload/install/FileBasedInstaller.cs index 170dda6cccd4..800078f10e37 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/FileBasedInstaller.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/install/FileBasedInstaller.cs @@ -514,6 +514,7 @@ public void UpdateInstallMode(SdkFeatureBand sdkFeatureBand, bool newMode) var installStateContents = InstallStateContents.FromPath(path); installStateContents.UseWorkloadSets = newMode; File.WriteAllText(path, installStateContents.ToString()); + _reporter.WriteLine(string.Format(LocalizableStrings.UpdatedWorkloadMode, newMode ? WorkloadConfigCommandParser.UpdateMode_WorkloadSet : WorkloadConfigCommandParser.UpdateMode_Manifests)); } /// diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/LocalizableStrings.resx b/src/Cli/dotnet/commands/dotnet-workload/install/LocalizableStrings.resx index bfe6c150700e..f354a3120a2c 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/LocalizableStrings.resx +++ b/src/Cli/dotnet/commands/dotnet-workload/install/LocalizableStrings.resx @@ -352,4 +352,10 @@ Updating workload version from {0} to {1}. + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + + Successfully updated workload install mode to use {0}. + diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/NetSdkMsiInstallerClient.cs b/src/Cli/dotnet/commands/dotnet-workload/install/NetSdkMsiInstallerClient.cs index 5e22f6bb329d..82d68b6e1fea 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/NetSdkMsiInstallerClient.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/install/NetSdkMsiInstallerClient.cs @@ -462,7 +462,7 @@ public void InstallWorkloadManifest(ManifestVersionUpdate manifestUpdate, ITrans }, rollback: () => { - InstallWorkloadManifestImplementation(manifestUpdate.Reverse(), offlineCache: null, isRollback: true); + InstallWorkloadManifestImplementation(manifestUpdate, offlineCache: null, isRollback: true, action: InstallAction.Uninstall); }); } catch (Exception e) @@ -472,7 +472,7 @@ public void InstallWorkloadManifest(ManifestVersionUpdate manifestUpdate, ITrans } } - void InstallWorkloadManifestImplementation(ManifestVersionUpdate manifestUpdate, DirectoryPath? offlineCache = null, bool isRollback = false) + void InstallWorkloadManifestImplementation(ManifestVersionUpdate manifestUpdate, DirectoryPath? offlineCache = null, bool isRollback = false, InstallAction action = InstallAction.Install) { ReportPendingReboot(); @@ -491,7 +491,7 @@ void InstallWorkloadManifestImplementation(ManifestVersionUpdate manifestUpdate, MsiPayload msi = GetCachedMsiPayload(msiPackageId, msiPackageVersion, offlineCache); VerifyPackage(msi); DetectState state = DetectPackage(msi.ProductCode, out Version installedVersion); - InstallAction plannedAction = PlanPackage(msi, state, InstallAction.Install, installedVersion); + InstallAction plannedAction = PlanPackage(msi, state, action, installedVersion); ExecutePackage(msi, plannedAction, msiPackageId); @@ -1081,6 +1081,10 @@ private void OnProcessExit(object sender, EventArgs e) } } - void IInstaller.UpdateInstallMode(SdkFeatureBand sdkFeatureBand, bool newMode) => UpdateInstallMode(sdkFeatureBand, newMode); + void IInstaller.UpdateInstallMode(SdkFeatureBand sdkFeatureBand, bool newMode) + { + UpdateInstallMode(sdkFeatureBand, newMode); + Reporter.WriteLine(string.Format(LocalizableStrings.UpdatedWorkloadMode, newMode ? WorkloadConfigCommandParser.UpdateMode_WorkloadSet : WorkloadConfigCommandParser.UpdateMode_Manifests)); + } } } diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadGarbageCollector.cs b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadGarbageCollector.cs index 8b75adb64743..88f0bda5a856 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadGarbageCollector.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadGarbageCollector.cs @@ -73,7 +73,12 @@ void GarbageCollectWorkloadSets() var resolver = GetResolver(); var installedWorkloadSets = resolver.GetWorkloadManifestProvider().GetAvailableWorkloadSets(); - + + foreach (var set in installedWorkloadSets.Keys) + { + WorkloadSetsToKeep.Add(set); + } + var installStateFilePath = Path.Combine(WorkloadInstallType.GetInstallStateFolder(_sdkFeatureBand, _dotnetDir), "default.json"); if (File.Exists(installStateFilePath)) { diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs index 7025e5a5bf2b..a03d3500e138 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs @@ -11,6 +11,7 @@ using Microsoft.DotNet.Cli.NuGetPackageDownloader; using Microsoft.Extensions.EnvironmentAbstractions; using static Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver; +using System.Text; namespace Microsoft.DotNet.Workloads.Workload.Install { @@ -44,14 +45,6 @@ public WorkloadInstallCommand( _workloadInstaller.GetWorkloadInstallationRecordRepository(), _workloadInstaller, _packageSourceLocation, displayManifestUpdates: Verbosity.IsDetailedOrDiagnostic()); _workloadSetVersion = parseResult.GetValue(InstallingWorkloadCommandParser.WorkloadSetVersionOption); - if (string.IsNullOrWhiteSpace(_workloadSetVersion)) - { - // If the version of the workload set is currently pinned, treat it as if it were freshly pinned. - var installStateContents = InstallStateContents.FromPath(Path.Combine(WorkloadInstallType.GetInstallStateFolder(_sdkFeatureBand, _dotnetPath), "default.json")); - _workloadSetVersion = installStateContents.WorkloadVersion; - } - - ValidateWorkloadIdsInput(); } private void ValidateWorkloadIdsInput() @@ -74,6 +67,8 @@ public override int Execute() bool usedRollback = !string.IsNullOrWhiteSpace(_fromRollbackDefinition); if (_printDownloadLinkOnly) { + ValidateWorkloadIdsInput(); + Reporter.WriteLine(string.Format(LocalizableStrings.ResolvingPackageUrls, string.Join(", ", _workloadIds))); // Take the union of the currently installed workloads and the ones that are being requested. This is so that if there are updates to the manifests @@ -90,6 +85,8 @@ public override int Execute() } else if (!string.IsNullOrWhiteSpace(_downloadToCacheOption)) { + ValidateWorkloadIdsInput(); + try { // Take the union of the currently installed workloads and the ones that are being requested. This is so that if there are updates to the manifests @@ -113,11 +110,34 @@ public override int Execute() } else { + var globaljsonPath = SdkDirectoryWorkloadManifestProvider.GetGlobalJsonPath(Environment.CurrentDirectory); + _workloadSetVersionFromGlobalJson = SdkDirectoryWorkloadManifestProvider.GlobalJsonReader.GetWorkloadVersionFromGlobalJson(globaljsonPath); + try { + ErrorIfGlobalJsonAndCommandLineMismatch(globaljsonPath); + + // Normally we want to validate that the workload IDs specified were valid. However, if there is a global.json file with a workload + // set version specified, and we might update the workload version, then we don't do that check here, because we might not have the right + // workload set installed yet, and trying to list the available workloads would throw an error + if (_skipManifestUpdate || string.IsNullOrEmpty(_workloadSetVersionFromGlobalJson)) + { + ValidateWorkloadIdsInput(); + } + + if (string.IsNullOrWhiteSpace(_workloadSetVersion) && string.IsNullOrWhiteSpace(_workloadSetVersionFromGlobalJson)) + { + var installStateFilePath = Path.Combine(WorkloadInstallType.GetInstallStateFolder(_sdkFeatureBand, _dotnetPath), "default.json"); + if (File.Exists(installStateFilePath)) + { + var installStateContents = InstallStateContents.FromPath(installStateFilePath); + _workloadSetVersion = installStateContents.WorkloadVersion; + } + } + DirectoryPath? offlineCache = string.IsNullOrWhiteSpace(_fromCacheOption) ? null : new DirectoryPath(_fromCacheOption); var workloadIds = _workloadIds.Select(id => new WorkloadId(id)); - if (string.IsNullOrWhiteSpace(_workloadSetVersion)) + if (string.IsNullOrWhiteSpace(_workloadSetVersion) && string.IsNullOrWhiteSpace(_workloadSetVersionFromGlobalJson)) { InstallWorkloads( workloadIds, @@ -129,9 +149,18 @@ public override int Execute() { RunInNewTransaction(context => { - var manifests = HandleWorkloadUpdateFromVersion(context, offlineCache); - InstallWorkloadsAndGarbageCollect(context, workloadIds, manifests, offlineCache, false); + if (!TryHandleWorkloadUpdateFromVersion(context, offlineCache, out var manifests)) + { + return; + } + InstallWorkloadsWithInstallRecord(context, _workloadInstaller, workloadIds, _sdkFeatureBand, manifests, offlineCache, false); }); + + TryRunGarbageCollection(_workloadInstaller, Reporter, Verbosity, workloadSetVersion => _workloadResolverFactory.CreateForWorkloadSet(_dotnetPath, _sdkVersion.ToString(), _userProfileDir, workloadSetVersion), offlineCache); + + Reporter.WriteLine(); + Reporter.WriteLine(string.Format(LocalizableStrings.InstallationSucceeded, string.Join(" ", workloadIds))); + Reporter.WriteLine(); } } catch (Exception e) @@ -157,7 +186,9 @@ public void InstallWorkloads(IEnumerable workloadIds, bool skipManif if (!skipManifestUpdate) { var installStateFilePath = Path.Combine(WorkloadInstallType.GetInstallStateFolder(_sdkFeatureBand, _dotnetPath), "default.json"); - if (string.IsNullOrWhiteSpace(_fromRollbackDefinition) && File.Exists(installStateFilePath) && InstallStateContents.FromString(File.ReadAllText(installStateFilePath)).Manifests is not null) + var installState = InstallStateContents.FromPath(installStateFilePath); + if (string.IsNullOrWhiteSpace(_fromRollbackDefinition) && string.IsNullOrWhiteSpace(_workloadSetVersion) && string.IsNullOrWhiteSpace(_workloadSetVersionFromGlobalJson) && + (installState?.Manifests is not null || installState?.WorkloadVersion is not null)) { // If there is a rollback state file, then we don't want to automatically update workloads when a workload is installed // To update to a new version, the user would need to run "dotnet workload update" @@ -189,7 +220,10 @@ public void InstallWorkloads(IEnumerable workloadIds, bool skipManif if (useWorkloadSets) { - manifestsToUpdate = InstallWorkloadSet(context); + if (!TryInstallWorkloadSet(context, out manifestsToUpdate)) + { + return; + } } else { @@ -198,13 +232,8 @@ public void InstallWorkloads(IEnumerable workloadIds, bool skipManif } } - InstallWorkloadsAndGarbageCollect(context, workloadIds, manifestsToUpdate, offlineCache, useRollback); + InstallWorkloadsWithInstallRecord(context, _workloadInstaller, workloadIds, _sdkFeatureBand, manifestsToUpdate, offlineCache, useRollback); }); - } - - private void InstallWorkloadsAndGarbageCollect(ITransactionContext context, IEnumerable workloadIds, IEnumerable manifestsToUpdate, DirectoryPath? offlineCache, bool useRollback) - { - InstallWorkloadsWithInstallRecord(context, _workloadInstaller, workloadIds, _sdkFeatureBand, manifestsToUpdate, offlineCache, useRollback); TryRunGarbageCollection(_workloadInstaller, Reporter, Verbosity, workloadSetVersion => _workloadResolverFactory.CreateForWorkloadSet(_dotnetPath, _sdkVersion.ToString(), _userProfileDir, workloadSetVersion), offlineCache); @@ -265,7 +294,10 @@ private void InstallWorkloadsWithInstallRecord( installer.SaveInstallStateManifestVersions(sdkFeatureBand, GetInstallStateContents(manifestsToUpdate)); } - installer.AdjustWorkloadSetInInstallState(sdkFeatureBand, string.IsNullOrWhiteSpace(_workloadSetVersion) ? null : _workloadSetVersion); + if (string.IsNullOrWhiteSpace(_workloadSetVersionFromGlobalJson)) + { + installer.AdjustWorkloadSetInInstallState(sdkFeatureBand, string.IsNullOrWhiteSpace(_workloadSetVersion) ? null : _workloadSetVersion); + } _workloadResolver.RefreshWorkloadManifests(); diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadManifestUpdater.cs b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadManifestUpdater.cs index bb91d359cdab..4c60548cebb4 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadManifestUpdater.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadManifestUpdater.cs @@ -88,10 +88,10 @@ public async Task UpdateAdvertisingManifestsAsync(bool includePreviews, bool use } } - public async void DownloadWorkloadSet(string version, DirectoryPath? offlineCache = null) + public void DownloadWorkloadSet(string version, DirectoryPath? offlineCache = null) { var correctedVersion = WorkloadSetVersionToWorkloadSetPackageVersion(version); - await UpdateManifestWithVersionAsync("Microsoft.NET.Workloads", includePreviews: true, _sdkFeatureBand, new NuGetVersion(correctedVersion), offlineCache); + Task.Run(() => UpdateManifestWithVersionAsync("Microsoft.NET.Workloads", includePreviews: true, _sdkFeatureBand, new NuGetVersion(correctedVersion), offlineCache)).Wait(); } public async static Task BackgroundUpdateAdvertisingManifestsAsync(string userProfileDir) @@ -247,14 +247,12 @@ public IEnumerable CalculateManifestRollbacks(string roll private IEnumerable CalculateManifestRollbacks(IEnumerable<(ManifestId Id, ManifestVersionWithBand ManifestWithBand)> versionUpdates) { - var manifestUpdates = versionUpdates.Select(manifest => + return versionUpdates.Select(manifest => { var (id, (version, band)) = manifest; var (installedVersion, installedBand) = GetInstalledManifestVersion(id); return new ManifestVersionUpdate(id, installedVersion, installedBand.ToString(), version, band.ToString()); }); - - return manifestUpdates; } public async Task> GetManifestPackageDownloadsAsync(bool includePreviews, SdkFeatureBand providedSdkFeatureBand, SdkFeatureBand installedSdkFeatureBand) @@ -475,26 +473,21 @@ private async Task NewerManifestPackageExists(ManifestId manifest) public IEnumerable ParseRollbackDefinitionFiles(IEnumerable rollbackFilePaths) { + var zeroVersion = new ManifestVersion("0.0.0"); if (rollbackFilePaths.Count() == 1) { - return CalculateManifestRollbacks(rollbackFilePaths.Single()); + return ParseRollbackDefinitionFile(rollbackFilePaths.Single(), _sdkFeatureBand).Select(manifest => + { + var (id, (version, band)) = manifest; + return new ManifestVersionUpdate(id, zeroVersion, band.ToString(), version, band.ToString()); + }); } - var currentManifestIds = GetInstalledManifestIds(); // Create a single workload set that includes all the others List<(ManifestId, ManifestVersionWithBand)> fullSet = new(); foreach (var rollbackFile in rollbackFilePaths) { - var rollbacks = ParseRollbackDefinitionFile(rollbackFile, _sdkFeatureBand); - - var unrecognizedManifestIds = rollbacks.Where(rollbackManifest => !currentManifestIds.Contains(rollbackManifest.Id)); - if (unrecognizedManifestIds.Any()) - { - _reporter.WriteLine(string.Format(LocalizableStrings.RollbackDefinitionContainsExtraneousManifestIds, rollbackFile, string.Join(" ", unrecognizedManifestIds)).Yellow()); - rollbacks = rollbacks.Where(rollbackManifest => currentManifestIds.Contains(rollbackManifest.Id)); - } - - fullSet.AddRange(rollbacks); + fullSet.AddRange(ParseRollbackDefinitionFile(rollbackFile, _sdkFeatureBand)); } var reducedFullSet = fullSet.DistinctBy<(ManifestId, ManifestVersionWithBand), ManifestId>(update => update.Item1).ToList(); @@ -504,7 +497,11 @@ public IEnumerable ParseRollbackDefinitionFiles(IEnumerab throw new ArgumentException("There were duplicates of the following manifests between the workload set files: " + string.Join(", ", duplicates)); } - return CalculateManifestRollbacks(fullSet); + return fullSet.Select(manifest => + { + var (id, (version, band)) = manifest; + return new ManifestVersionUpdate(id, zeroVersion, band.ToString(), version, band.ToString()); + }); } private static IEnumerable<(ManifestId Id, ManifestVersionWithBand ManifestWithBand)> ParseRollbackDefinitionFile(string rollbackDefinitionFilePath, SdkFeatureBand featureBand) diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.cs.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.cs.xlf index 76013b91be7c..1df9e9ebb634 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.cs.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.cs.xlf @@ -22,6 +22,11 @@ Možnosti {0} a {1} nelze použít společně. Při instalaci ze souboru vráceného zpět odeberte {0}. V opačném případě odeberte {1}. + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. Kontrolují se aktualizované manifesty úloh. @@ -282,6 +287,11 @@ Vytiskne pouze seznam odkazů, které se mají stáhnout, aniž by se tento seznam stahoval. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. Instaluje se balíček {0} verze {1} z offline mezipaměti {2}. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.de.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.de.xlf index a44263689d79..cdf67e7336ef 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.de.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.de.xlf @@ -22,6 +22,11 @@ Die Optionen {0} und {1} können nicht zusammen verwendet werden. Entfernen Sie bei der Installation aus einer Rollbackdatei {0}. Entfernen Sie andernfalls {1} + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. Es wird nach aktualisierten Workloadmanifesten gesucht. @@ -282,6 +287,11 @@ Drucken Sie nur die Liste der Links zum Herunterladen, ohne sie herunterzuladen. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. Das Paket "{0}", Version {1}, aus dem Offlinecache "{2}" wird installiert. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.es.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.es.xlf index a75cebc92ce9..8fc65b98a8f4 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.es.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.es.xlf @@ -22,6 +22,11 @@ No se pueden usar las opciones {0} y {1} juntas. Si se instala desde un archivo de reversión, quite {0}. De lo contrario, quite {1} + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. Comprobando si hay manifiestos de carga de trabajo actualizados. @@ -282,6 +287,11 @@ Imprima solo la lista de vínculos para descargar, sin descargarla. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. Instalando el paquete {0}, versión {1} desde la caché sin conexión {2}. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.fr.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.fr.xlf index 6c6090b6f272..294d00289573 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.fr.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.fr.xlf @@ -22,6 +22,11 @@ Impossible d’utiliser les options {0} et {1} ensemble. Si vous installez à partir d’un fichier de restauration, supprimez {0}. Sinon, supprimez {1}. + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. Recherche de manifestes de charge de travail mis à jour @@ -282,6 +287,11 @@ Imprimer uniquement la liste des liens à télécharger sans télécharger. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. Installation du {0} de {1} la version du package à partir du {2} de cache hors connexion. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.it.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.it.xlf index 7a5067400e8a..e397bc436373 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.it.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.it.xlf @@ -22,6 +22,11 @@ Impossibile utilizzare contemporaneamente le opzioni {0} e {1}. Se si esegue l'installazione da un file di rollback, rimuovere {0}. In caso contrario, rimuovere {1} + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. Verifica della disponibilità di manifesti del carico di lavoro aggiornati. @@ -282,6 +287,11 @@ Stampa solo l'elenco dei collegamenti da scaricare senza scaricarlo. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. Installazione del pacchetto {0}, versione {1}, dalla cache offline {2}. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ja.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ja.xlf index a31e86c77a7d..d5ea9b1cb78d 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ja.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ja.xlf @@ -22,6 +22,11 @@ {0} オプションと {1} オプションを併用することはできません。ロールバック ファイルからインストールする場合、{0} を削除してください。その他の場合には、{1} を削除します + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. 更新されたワークロード マニフェストを確認しています。 @@ -282,6 +287,11 @@ ダウンロードするリンクの一覧をダウンロードせず、印刷だけを行います。 + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. オフライン キャッシュ {2} でパッケージ {0} のバージョン {1} をインストールしています。 diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ko.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ko.xlf index 12407ab1d966..ebd44f012d73 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ko.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ko.xlf @@ -22,6 +22,11 @@ {0} 및 {1} 옵션을 함께 사용할 수 없습니다. 롤백 파일에서 설치하는 경우 {0}을(를) 제거합니다. 그렇지 않으면 {1}을(를) 제거합니다. + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. 업데이트된 워크로드 매니페스트를 확인하는 중입니다. @@ -282,6 +287,11 @@ 다운로드할 링크 목록을 다운로드하지 않고 인쇄만 합니다. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. 오프라인 캐시 {2}에서 패키지 {0} 버전 {1}(을)를 설치하는 중입니다. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.pl.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.pl.xlf index a784788b99f0..3e61746bc72c 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.pl.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.pl.xlf @@ -22,6 +22,11 @@ Nie można jednocześnie używać poleceń {0} i {1}. W przypadku instalowania z pliku wycofywania usuń polecenie {0}. W przeciwnym razie usuń polecenie {1} + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. Sprawdzanie zaktualizowanych manifestów obciążenia. @@ -282,6 +287,11 @@ Drukuj tylko listę linków do pobrania bez ich pobierania. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. Instalowanie pakietu {0} w wersji {1} z pamięci podręcznej w trybie offline {2}. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.pt-BR.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.pt-BR.xlf index 3868ca862661..a583d3c85863 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.pt-BR.xlf @@ -22,6 +22,11 @@ Não é possível usar as opções {0} e {1} juntas. Se estiver instalando a partir de um arquivo de reversão, remova {0}. Caso contrário, remova {1} + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. Verificando manifestos de carga de trabalho atualizados. @@ -282,6 +287,11 @@ Somente imprimir a lista de links para download sem baixá-la. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. Instalando o pacote {0} versão {1} do cache offline {2}. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ru.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ru.xlf index 118f305e080c..2b15f6ee5ea6 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ru.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ru.xlf @@ -22,6 +22,11 @@ Невозможно использовать параметры {0} и {1} одновременно. При установке из файла отката удалите {0}, в противном случае удалите {1}. + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. Проверка обновленных манифестов рабочей нагрузки. @@ -282,6 +287,11 @@ Печатать только список ссылок для скачивания, не выполняя загрузку. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. Установка пакета {0} версии {1} из автономного кэша {2}. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.tr.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.tr.xlf index 7e3b417ba5d8..af3e34522f43 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.tr.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.tr.xlf @@ -22,6 +22,11 @@ {0} ve {1} seçenekleri birlikte kullanılamıyor. Bir geri alma dosyasından yükleniyorsa {0} seçeneğini kaldırın. Aksi takdirde, {1} seçeneğini kaldırın + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. Güncelleştirilmiş iş yükü bildirimleri denetleniyor. @@ -282,6 +287,11 @@ İndirmeden, yalnızca indirilecek bağlantıların listesini yazdırın. + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. {0} paketi sürüm {1}, {2} çevrimdışı önbelleğinden yükleniyor. diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.zh-Hans.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.zh-Hans.xlf index fddbca0c8a49..ecfae003c7a1 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.zh-Hans.xlf @@ -22,6 +22,11 @@ 不能同时使用 {0} 和 {1} 选项。如果从回滚文件安装,请删除 {0}。否则,请删除 {1} + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. 正在检查更新的工作负载清单。 @@ -282,6 +287,11 @@ 仅打印要下载的链接的列表,而不下载列表。 + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. 正在从脱机缓存 {2} 安装程序包 {0} 版本 {1}。 diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.zh-Hant.xlf b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.zh-Hant.xlf index 43d76325d2dd..cc996102fd0b 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.zh-Hant.xlf @@ -22,6 +22,11 @@ 無法同時使用 {0} 與 {1} 選項。如果從復原檔案安裝,請移除 {0}。否則,請移除 {1} + + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + Cannot specify a particular workload version on the command line via --version or --from-history when there is already a version specified in global.json file {0}. To update the globally installed workload version, run the command outside of the path containing that global.json file or update the version specified in the global.json file and run "dotnet workload update." + + Checking for updated workload manifests. 正在檢查更新的工作負載資訊清單。 @@ -282,6 +287,11 @@ 只列印要下載的連結清單,而不下載。 + + Successfully updated workload install mode to use {0}. + Successfully updated workload install mode to use {0}. + + Installing package {0} version {1} from offline cache {2}. 正在從離線快取 {2} 安裝套件 {0} 版本 {1}。 diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/LocalizableStrings.resx b/src/Cli/dotnet/commands/dotnet-workload/list/LocalizableStrings.resx index dbb30fdcd881..4ba629fee8d5 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/LocalizableStrings.resx +++ b/src/Cli/dotnet/commands/dotnet-workload/list/LocalizableStrings.resx @@ -131,4 +131,10 @@ Workload version: {0} + + Found workload version {0} pinned in the global.json file at {1}. + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + \ No newline at end of file diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/WorkloadListCommand.cs b/src/Cli/dotnet/commands/dotnet-workload/list/WorkloadListCommand.cs index 93dcc18f90f3..3541d6729c4e 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/WorkloadListCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/list/WorkloadListCommand.cs @@ -77,29 +77,46 @@ public override int Execute() } else { - var manifestInfoDict = _workloadListHelper.WorkloadResolver.GetInstalledManifests().ToDictionary(info => info.Id, StringComparer.OrdinalIgnoreCase); - - InstalledWorkloadsCollection installedWorkloads = _workloadListHelper.AddInstalledVsWorkloads(installedList); + var globalJsonInformation = _workloadListHelper.ManifestProvider.GetGlobalJsonInformation(); Reporter.WriteLine(); - PrintableTable> table = new(); - table.AddColumn(InformationStrings.WorkloadIdColumn, workload => workload.Key); - table.AddColumn(InformationStrings.WorkloadManfiestVersionColumn, workload => + if (globalJsonInformation is not null) { - var m = _workloadListHelper.WorkloadResolver.GetManifestFromWorkload(new WorkloadId(workload.Key)); - var manifestInfo = manifestInfoDict[m.Id]; - return m.Version + "/" + manifestInfo.ManifestFeatureBand; - }); - table.AddColumn(InformationStrings.WorkloadSourceColumn, workload => workload.Value); - - table.PrintRows(installedWorkloads.AsEnumerable(), l => Reporter.WriteLine(l)); + Reporter.WriteLine(string.Format( + globalJsonInformation.WorkloadVersionInstalled ? + LocalizableStrings.WorkloadSetFromGlobalJsonInstalled : + LocalizableStrings.WorkloadSetFromGlobalJsonNotInstalled, + globalJsonInformation.GlobalJsonVersion, + globalJsonInformation.GlobalJsonPath)); + } - var installState = InstallStateContents.FromPath(Path.Combine(WorkloadInstallType.GetInstallStateFolder(_workloadListHelper._currentSdkFeatureBand, _workloadListHelper.DotnetPath), "default.json")); - if (installState.UseWorkloadSets == true) + if (globalJsonInformation?.WorkloadVersionInstalled != false) { - Reporter.WriteLine(); - Reporter.WriteLine(string.Format(LocalizableStrings.WorkloadSetVersion, _workloadListHelper.WorkloadResolver.GetWorkloadVersion() ?? "unknown")); + var manifestInfoDict = _workloadListHelper.WorkloadResolver.GetInstalledManifests().ToDictionary(info => info.Id, StringComparer.OrdinalIgnoreCase); + + InstalledWorkloadsCollection installedWorkloads = _workloadListHelper.AddInstalledVsWorkloads(installedList); + PrintableTable> table = new(); + table.AddColumn(InformationStrings.WorkloadIdColumn, workload => workload.Key); + table.AddColumn(InformationStrings.WorkloadManfiestVersionColumn, workload => + { + var m = _workloadListHelper.WorkloadResolver.GetManifestFromWorkload(new WorkloadId(workload.Key)); + var manifestInfo = manifestInfoDict[m.Id]; + return m.Version + "/" + manifestInfo.ManifestFeatureBand; + }); + table.AddColumn(InformationStrings.WorkloadSourceColumn, workload => workload.Value); + + table.PrintRows(installedWorkloads.AsEnumerable(), l => Reporter.WriteLine(l)); + + if (globalJsonInformation is null) + { + var installState = InstallStateContents.FromPath(Path.Combine(WorkloadInstallType.GetInstallStateFolder(_workloadListHelper._currentSdkFeatureBand, _workloadListHelper.DotnetPath), "default.json")); + if (installState.UseWorkloadSets == true) + { + Reporter.WriteLine(); + Reporter.WriteLine(string.Format(LocalizableStrings.WorkloadSetVersion, _workloadListHelper.WorkloadResolver.GetWorkloadVersion() ?? "unknown")); + } + } } - + Reporter.WriteLine(); Reporter.WriteLine(LocalizableStrings.WorkloadListFooter); Reporter.WriteLine(); diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.cs.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.cs.xlf index d7357b6c0252..8388d4cf809b 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.cs.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.cs.xlf @@ -12,6 +12,16 @@ Pokud chcete najít další úlohy, které se mají nainstalovat, použijte `dotnet workload search`. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} Verze úlohy: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.de.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.de.xlf index b1f539bb2690..2b7cae8f5685 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.de.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.de.xlf @@ -12,6 +12,16 @@ Verwenden Sie „dotnet workload search“, um zusätzliche zu installierende Workloads zu finden. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} Workloadversion: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.es.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.es.xlf index 8218b465574c..61884ae6ed7e 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.es.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.es.xlf @@ -12,6 +12,16 @@ Use "dotnet workload search" para buscar cargas de trabajo adicionales para instalar. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} Versión de carga de trabajo: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.fr.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.fr.xlf index 048b86c1be46..d2e2ea674228 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.fr.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.fr.xlf @@ -12,6 +12,16 @@ Utilisez `dotnet workload search` pour rechercher d’autres charges de travail à installer. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} Version de la charge de travail : {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.it.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.it.xlf index 3c864a9ac70e..91f794a602b6 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.it.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.it.xlf @@ -12,6 +12,16 @@ Utilizzare la `dotnet workload search` per trovare i carichi di lavoro aggiuntivi da installare. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} Versione carico di lavoro: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ja.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ja.xlf index cfa7663bd2c1..3acc87707e82 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ja.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ja.xlf @@ -12,6 +12,16 @@ `dotnet workload search` を使用して追加ワークロードを検出し、インストールします。 {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} ワークロードのバージョン: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ko.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ko.xlf index 133c3c43265c..ce709a90f339 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ko.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ko.xlf @@ -12,6 +12,16 @@ `dotnet workload search`을 사용하여 설치할 추가 워크로드를 찾습니다. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} 워크로드 버전: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.pl.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.pl.xlf index 73887307cace..be461cd2b5cf 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.pl.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.pl.xlf @@ -12,6 +12,16 @@ Użyj polecenia „dotnet workload search”, aby znaleźć dodatkowe obciążenia do zainstalowania. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} Wersja obciążenia: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.pt-BR.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.pt-BR.xlf index f6fadc51c77f..a13ba8c15c7f 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.pt-BR.xlf @@ -12,6 +12,16 @@ Use `dotnet workload search` para encontrar cargas de trabalho adicionais a serem instaladas. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} Versão da carga de trabalho: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ru.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ru.xlf index c5eaafb29ba7..9e3f006b8719 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ru.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.ru.xlf @@ -12,6 +12,16 @@ Используйте `dotnet workload search`, чтобы найти дополнительные рабочие нагрузки для установки. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} Версия рабочей нагрузки: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.tr.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.tr.xlf index d06bed8d2488..e289bc9ebf2c 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.tr.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.tr.xlf @@ -12,6 +12,16 @@ Yüklenecek ek iş yüklerini bulmak için `dotnet workload search` kullanın. {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} İş yükü sürümü: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.zh-Hans.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.zh-Hans.xlf index fb1e4caff827..34c6cab624a8 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.zh-Hans.xlf @@ -12,6 +12,16 @@ 使用`dotnet workload search`查找要安装的其他工作负载。 {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} 工作负载版本:{0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.zh-Hant.xlf b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.zh-Hant.xlf index c17b8f9ccd3b..95b3e8cb3d85 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/list/xlf/LocalizableStrings.zh-Hant.xlf @@ -12,6 +12,16 @@ 使用 `dotnet workload search` 尋找其他要安裝的工作負載。 {Locked="dotnet workload search"} + + Found workload version {0} pinned in the global.json file at {1}. + Found workload version {0} pinned in the global.json file at {1}. + + + + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + Found workload version {0} pinned in the global.json file at {1}, but it was not installed. Running `dotnet workload install`, `dotnet workload update`, or `dotnet workload restore` may fix this. + + Workload version: {0} 工作負載版本: {0} diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/LocalizableStrings.resx b/src/Cli/dotnet/commands/dotnet-workload/update/LocalizableStrings.resx index 7121fc1dab52..324afaefc484 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/LocalizableStrings.resx +++ b/src/Cli/dotnet/commands/dotnet-workload/update/LocalizableStrings.resx @@ -156,4 +156,7 @@ Updating to a rollback file is not compatible with workload sets. Install and Update will now use loose manifests. To update to a specific workload version, use --version. + + No workload update found. + diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/WorkloadUpdateCommand.cs b/src/Cli/dotnet/commands/dotnet-workload/update/WorkloadUpdateCommand.cs index 0305f2370e26..7bd8614085c9 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/WorkloadUpdateCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/update/WorkloadUpdateCommand.cs @@ -91,10 +91,14 @@ public override int Execute() } else { + var globaljsonPath = SdkDirectoryWorkloadManifestProvider.GetGlobalJsonPath(Environment.CurrentDirectory); + _workloadSetVersionFromGlobalJson = SdkDirectoryWorkloadManifestProvider.GlobalJsonReader.GetWorkloadVersionFromGlobalJson(globaljsonPath); + try { + ErrorIfGlobalJsonAndCommandLineMismatch(globaljsonPath); DirectoryPath? offlineCache = string.IsNullOrWhiteSpace(_fromCacheOption) ? null : new DirectoryPath(_fromCacheOption); - if (string.IsNullOrWhiteSpace(_workloadSetVersion)) + if (string.IsNullOrWhiteSpace(_workloadSetVersion) && string.IsNullOrWhiteSpace(_workloadSetVersionFromGlobalJson)) { CalculateManifestUpdatesAndUpdateWorkloads(_includePreviews, offlineCache); } @@ -102,7 +106,10 @@ public override int Execute() { RunInNewTransaction(context => { - var manifestUpdates = HandleWorkloadUpdateFromVersion(context, offlineCache); + if (!TryHandleWorkloadUpdateFromVersion(context, offlineCache, out var manifestUpdates)) + { + return; + } UpdateWorkloads(false, manifestUpdates, offlineCache, context); }); } @@ -142,7 +149,10 @@ public void CalculateManifestUpdatesAndUpdateWorkloads(bool includePreviews = fa { if (useWorkloadSets) { - manifestsToUpdate = InstallWorkloadSet(context); + if (!TryInstallWorkloadSet(context, out manifestsToUpdate)) + { + return; + } } else { @@ -151,11 +161,15 @@ public void CalculateManifestUpdatesAndUpdateWorkloads(bool includePreviews = fa } UpdateWorkloads(useRollback, manifestsToUpdate, offlineCache, context); - - Reporter.WriteLine(); - Reporter.WriteLine(string.Format(LocalizableStrings.UpdateSucceeded, string.Join(" ", workloadIds))); - Reporter.WriteLine(); }); + + WorkloadInstallCommand.TryRunGarbageCollection(_workloadInstaller, Reporter, Verbosity, workloadSetVersion => _workloadResolverFactory.CreateForWorkloadSet(_dotnetPath, _sdkVersion.ToString(), _userProfileDir, workloadSetVersion), offlineCache); + + _workloadManifestUpdater.DeleteUpdatableWorkloadsFile(); + + Reporter.WriteLine(); + Reporter.WriteLine(string.Format(LocalizableStrings.UpdateSucceeded, string.Join(" ", workloadIds))); + Reporter.WriteLine(); } private void UpdateWorkloads(bool useRollback, IEnumerable manifestsToUpdate, DirectoryPath? offlineCache, ITransactionContext context) @@ -163,10 +177,6 @@ private void UpdateWorkloads(bool useRollback, IEnumerable _workloadResolverFactory.CreateForWorkloadSet(_dotnetPath, _sdkVersion.ToString(), _userProfileDir, workloadSetVersion), offlineCache); - - _workloadManifestUpdater.DeleteUpdatableWorkloadsFile(); } private void WriteSDKInstallRecordsForVSWorkloads(IEnumerable updateableWorkloads) @@ -203,7 +213,10 @@ private void UpdateWorkloadsWithInstallRecord( _workloadInstaller.RemoveManifestsFromInstallState(sdkFeatureBand); } - _workloadInstaller.AdjustWorkloadSetInInstallState(sdkFeatureBand, string.IsNullOrWhiteSpace(_workloadSetVersion) ? null : _workloadSetVersion); + if (string.IsNullOrWhiteSpace(_workloadSetVersionFromGlobalJson)) + { + _workloadInstaller.AdjustWorkloadSetInInstallState(sdkFeatureBand, string.IsNullOrWhiteSpace(_workloadSetVersion) ? null : _workloadSetVersion); + } _workloadResolver.RefreshWorkloadManifests(); diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.cs.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.cs.xlf index 2bda96c4722a..24be3f66a912 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.cs.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.cs.xlf @@ -22,6 +22,11 @@ Aktualizuje úlohy na základě zadaného souboru definice vrácení zpět. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. Pro toto pásmo funkcí nejsou nainstalované žádné úlohy. Pokud chcete provést aktualizaci úlohy nainstalované z předchozí sady SDK, přidejte možnost --from-previous-sdk. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.de.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.de.xlf index 05b1a8b2e007..8e8e3bd1d83a 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.de.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.de.xlf @@ -22,6 +22,11 @@ Aktualisieren Sie Workloads basierend auf der angegebenen Rollbackdefinitionsdatei. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. Für diesen Featurebereich sind keine Workloads installiert. Um Workloads zu aktualisieren, die mit früheren SDK-Versionen installiert wurden, schließen Sie die Option „--from-previous-sdk“ ein. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.es.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.es.xlf index a3b8b2e1d792..c0ce635a45f8 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.es.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.es.xlf @@ -22,6 +22,11 @@ Actualice las cargas de trabajo en función del archivo de definición de reversión especificado. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. No hay cargas de trabajo instaladas para esta banda de características. Para actualizar las cargas de trabajo instaladas con versiones anteriores del SDK, incluya la opción --from-previous-sdk. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.fr.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.fr.xlf index 08c5734fb317..f27d84da20d2 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.fr.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.fr.xlf @@ -22,6 +22,11 @@ Mettez à jour les charges de travail en fonction du fichier de définition de restauration spécifié. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. Aucune charge de travail installée pour cette bande de fonctionnalités. Pour mettre à jour les charges de travail installées avec des versions antérieures du SDK, incluez l'option --from-previous-sdk. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.it.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.it.xlf index 3040c6880e23..653623c16e96 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.it.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.it.xlf @@ -22,6 +22,11 @@ Aggiornare i carichi di lavoro in base al file di definizione di ripristino dello stato precedente specificato. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. Nessun carico di lavoro installato per questa banda di caratteristiche. Per eseguire l'aggiornamento da un SDK precedente, includere l'opzione --from-previous-sdk. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ja.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ja.xlf index d7c572c9aa44..610bdd4af408 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ja.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ja.xlf @@ -22,6 +22,11 @@ 指定されたロールバック定義ファイルに基づいてワークロードを更新します。 + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. この機能バンドにはワークロードがインストールされていません。以前の SDK バージョンでインストールしたワークロードを更新するには、--from-previous-sdk オプションを含めます。 diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ko.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ko.xlf index 68df940257eb..baca0da297dd 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ko.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ko.xlf @@ -22,6 +22,11 @@ 지정된 롤백 정의 파일을 기반으로 워크로드를 업데이트합니다. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. 이 기능 밴드에 대해 설치된 워크로드가 없습니다. 이전 SDK 버전으로 설치된 워크로드를 업데이트하려면 --from-previous-sdk 옵션을 포함합니다. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.pl.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.pl.xlf index 968f9e2b24fb..40d51a642576 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.pl.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.pl.xlf @@ -22,6 +22,11 @@ Zaktualizuj obciążenia na podstawie określonego pliku definicji wycofywania. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. Nie zainstalowano żadnych obciążeń dla tego pasma funkcji. Aby zaktualizować obciążenia zainstalowane przy użyciu wcześniejszych wersji zestawu SDK, dołącz opcję --from-previous-sdk. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.pt-BR.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.pt-BR.xlf index 9580e9b05508..0e22c2eced52 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.pt-BR.xlf @@ -22,6 +22,11 @@ Atualizar cargas de trabalho com base no arquivo de definição de reversão especificado. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. Nenhuma carga de trabalho instalada para esta faixa de recursos. Para atualizar cargas de trabalho instaladas com versões anteriores do SDK, inclua a opção --from-previous-sdk. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ru.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ru.xlf index 1b13510a65be..a7a92ade80f8 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ru.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ru.xlf @@ -22,6 +22,11 @@ Обновление рабочих нагрузок на основе указанного файла определения отката. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. Для этого диапазона функций не установлены рабочие нагрузки. Чтобы обновить рабочие нагрузки, установленные в более ранних версиях SDK, включите параметр --from-previous-sdk. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.tr.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.tr.xlf index fdb8fb481136..954b8372a770 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.tr.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.tr.xlf @@ -22,6 +22,11 @@ İş yüklerini belirtilen geri alma tanım dosyasına göre güncelleştirin. + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. Bu özellik bandı için iş yükü yüklenmedi. Önceki SDK sürümleriyle yüklenen iş yüklerini güncelleştirmek için --from-previous-sdk seçeneğini ekleyin. diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.zh-Hans.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.zh-Hans.xlf index 8d5aac17dab2..0c6848bd6867 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.zh-Hans.xlf @@ -22,6 +22,11 @@ 基于指定的回滚定义文件更新工作负载。 + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. 没有为此功能带安装工作负载。若要使用更早的 SDK 版本更新已安装的工作负载,请包括“the --from-previous-sdk”选项。 diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.zh-Hant.xlf b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.zh-Hant.xlf index ef0d84b155cd..f17b6f00fa5c 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.zh-Hant.xlf @@ -22,6 +22,11 @@ 根據指定的復原定義檔更新工作負載。 + + No workload update found. + No workload update found. + + No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option. 此功能帶未安裝任何工作負載。若要更新與舊版本 SDK 一起安裝的工作負載,請包含 --from-previous-sdk 選項。 diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.GlobalJsonReader.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.GlobalJsonReader.cs index 43dd03f24073..bd09adbfcdc8 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.GlobalJsonReader.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.GlobalJsonReader.cs @@ -16,7 +16,7 @@ namespace Microsoft.NET.Sdk.WorkloadManifestReader { public partial class SdkDirectoryWorkloadManifestProvider { - static class GlobalJsonReader + public static class GlobalJsonReader { public static string? GetWorkloadVersionFromGlobalJson(string? globalJsonPath) { diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs index 3ec592ccd955..564af9deb780 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs @@ -27,6 +27,12 @@ public partial class SdkDirectoryWorkloadManifestProvider : IWorkloadManifestPro private WorkloadSet? _manifestsFromInstallState; private string? _installStateFilePath; + // This will be non-null if there is an error loading manifests that should be thrown when they need to be accessed. + // We delay throwing the error so that in the case where global.json specifies a workload set that isn't installed, + // we can successfully construct a resolver and install that workload set + private Exception? _exceptionToThrow = null; + string? _globalJsonWorkloadSetVersion; + public SdkDirectoryWorkloadManifestProvider(string sdkRootPath, string sdkVersion, string? userProfileDir, string? globalJsonPath) : this(sdkRootPath, sdkVersion, Environment.GetEnvironmentVariable, userProfileDir, globalJsonPath) { @@ -107,6 +113,13 @@ internal SdkDirectoryWorkloadManifestProvider(string sdkRootPath, string sdkVers public void RefreshWorkloadManifests() { + // Reset exception state, we may be refreshing manifests after a missing workload set was installed + _exceptionToThrow = null; + _globalJsonWorkloadSetVersion = null; + + _workloadSet = null; + _manifestsFromInstallState = null; + _installStateFilePath = null; var availableWorkloadSets = GetAvailableWorkloadSets(); if (_workloadSetVersionFromConstructor != null) @@ -116,32 +129,38 @@ public void RefreshWorkloadManifests() throw new FileNotFoundException(string.Format(Strings.WorkloadVersionNotFound, _workloadSetVersionFromConstructor)); } } - else + + if (_workloadSet is null) { - string? globalJsonWorkloadSetVersion = GlobalJsonReader.GetWorkloadVersionFromGlobalJson(_globalJsonPathFromConstructor); - if (globalJsonWorkloadSetVersion != null) + _globalJsonWorkloadSetVersion = GlobalJsonReader.GetWorkloadVersionFromGlobalJson(_globalJsonPathFromConstructor); + if (_globalJsonWorkloadSetVersion != null) { - if (!availableWorkloadSets.TryGetValue(globalJsonWorkloadSetVersion, out _workloadSet)) + if (!availableWorkloadSets.TryGetValue(_globalJsonWorkloadSetVersion, out _workloadSet)) { - throw new FileNotFoundException(string.Format(Strings.WorkloadVersionFromGlobalJsonNotFound, globalJsonWorkloadSetVersion, _globalJsonPathFromConstructor)); + _exceptionToThrow = new FileNotFoundException(string.Format(Strings.WorkloadVersionFromGlobalJsonNotFound, _globalJsonWorkloadSetVersion, _globalJsonPathFromConstructor)); + return; } } - else + } + + if (_workloadSet is null) + { + var installStateFilePath = Path.Combine(WorkloadInstallType.GetInstallStateFolder(_sdkVersionBand, _sdkRootPath), "default.json"); + if (File.Exists(installStateFilePath)) { - var installStateFilePath = Path.Combine(WorkloadInstallType.GetInstallStateFolder(_sdkVersionBand, _sdkRootPath), "default.json"); - if (File.Exists(installStateFilePath)) + var installState = InstallStateContents.FromPath(installStateFilePath); + if (!string.IsNullOrEmpty(installState.WorkloadVersion)) { - var installState = InstallStateContents.FromPath(installStateFilePath); - if (!string.IsNullOrEmpty(installState.WorkloadVersion)) + if (!availableWorkloadSets.TryGetValue(installState.WorkloadVersion!, out _workloadSet)) { - if (!availableWorkloadSets.TryGetValue(installState.WorkloadVersion!, out _workloadSet)) - { - throw new FileNotFoundException(string.Format(Strings.WorkloadVersionFromInstallStateNotFound, installState.WorkloadVersion, installStateFilePath)); - } + throw new FileNotFoundException(string.Format(Strings.WorkloadVersionFromInstallStateNotFound, installState.WorkloadVersion, installStateFilePath)); } - _manifestsFromInstallState = installState.Manifests is null ? new WorkloadSet() : WorkloadSet.FromDictionaryForJson(installState.Manifests, _sdkVersionBand); - _installStateFilePath = installStateFilePath; } + + // Note: It is possible here to have both a workload set and loose manifests listed in the install state. This might happen if there is a + // third-party workload manifest installed that's not part of the workload set + _manifestsFromInstallState = installState.Manifests is null ? null : WorkloadSet.FromDictionaryForJson(installState.Manifests, _sdkVersionBand); + _installStateFilePath = installStateFilePath; } } @@ -152,8 +171,23 @@ public void RefreshWorkloadManifests() } } + void ThrowExceptionIfManifestsNotAvailable() + { + if (_exceptionToThrow != null) + { + throw _exceptionToThrow; + } + } + public string? GetWorkloadVersion() { + if (_globalJsonWorkloadSetVersion != null) + { + return _globalJsonWorkloadSetVersion; + } + + ThrowExceptionIfManifestsNotAvailable(); + if (_workloadSet?.Version is not null) { return _workloadSet?.Version!; @@ -179,6 +213,8 @@ public void RefreshWorkloadManifests() public IEnumerable GetManifests() { + ThrowExceptionIfManifestsNotAvailable(); + // Scan manifest directories var manifestIdsToManifests = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -467,5 +503,25 @@ public string GetSdkFeatureBand() } return null; } + + public GlobalJsonInformation? GetGlobalJsonInformation() + { + return _globalJsonWorkloadSetVersion is null || _globalJsonPathFromConstructor is null ? + null : + new GlobalJsonInformation(_globalJsonPathFromConstructor, _globalJsonWorkloadSetVersion, _exceptionToThrow is null); + } + + public record GlobalJsonInformation + { + public string GlobalJsonPath { get; } + public string GlobalJsonVersion { get; } + public bool WorkloadVersionInstalled { get; } + public GlobalJsonInformation(string path, string version, bool installed) + { + GlobalJsonPath = path; + GlobalJsonVersion = version; + WorkloadVersionInstalled = installed; + } + } } } diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/TempDirectoryWorkloadManifestProvider.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/TempDirectoryWorkloadManifestProvider.cs index a764fb2d9fb5..79d1351d9f90 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/TempDirectoryWorkloadManifestProvider.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/TempDirectoryWorkloadManifestProvider.cs @@ -16,8 +16,7 @@ public TempDirectoryWorkloadManifestProvider(string manifestsPath, string sdkFea public void RefreshWorkloadManifests() { } - public IEnumerable - GetManifests() + public IEnumerable GetManifests() { foreach (var workloadManifestDirectory in GetManifestDirectories()) { diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs index 81fdae3f4c2d..90a3137c9ded 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs @@ -23,6 +23,7 @@ public class WorkloadResolver : IWorkloadResolver private IWorkloadManifestProvider _manifestProvider; private string[] _currentRuntimeIdentifiers; private readonly (string path, bool installable)[] _dotnetRootPaths; + private bool _initializedManifests = false; private Func? _fileExistOverride; private Func? _directoryExistOverride; @@ -81,9 +82,16 @@ private WorkloadResolver(IWorkloadManifestProvider manifestProvider, (string pat : this(dotnetRootPaths, currentRuntimeIdentifiers, manifestProvider.GetSdkFeatureBand()) { _manifestProvider = manifestProvider; + } - LoadManifestsFromProvider(manifestProvider); - ComposeWorkloadManifests(); + private void InitializeManifests() + { + if (!_initializedManifests) + { + LoadManifestsFromProvider(_manifestProvider); + ComposeWorkloadManifests(); + _initializedManifests = true; + } } /// @@ -105,8 +113,8 @@ public void RefreshWorkloadManifests() _manifestProvider.RefreshWorkloadManifests(); _manifests.Clear(); - LoadManifestsFromProvider(_manifestProvider); - ComposeWorkloadManifests(); + _initializedManifests = false; + InitializeManifests(); } public string? GetWorkloadVersion() => _manifestProvider.GetWorkloadVersion(); @@ -232,6 +240,7 @@ private void ComposeWorkloadManifests() /// public IEnumerable GetInstalledWorkloadPacksOfKind(WorkloadPackKind kind) { + InitializeManifests(); foreach ((var pack, _) in _packs.Values) { if (pack.Kind != kind) @@ -361,6 +370,7 @@ string GetPackPath(WorkloadPackId resolvedPackageId, string packageVersion, Work /// private HashSet GetInstalledPacks() { + InitializeManifests(); var installedPacks = new HashSet(); foreach ((WorkloadPackId id, (WorkloadPack pack, WorkloadManifest _)) in _packs) { @@ -380,6 +390,8 @@ public IEnumerable GetPacksInWorkload(WorkloadId workloadId) throw new ArgumentException($"'{nameof(workloadId)}' cannot be null or empty", nameof(workloadId)); } + InitializeManifests(); + if (!_workloads.TryGetValue(workloadId, out var value)) { throw new Exception($"Workload not found: {workloadId}. Known workloads: {string.Join(" ", _workloads.Select(workload => workload.Key.ToString()))}"); @@ -418,6 +430,7 @@ public IEnumerable GetExtendedWorkloads(IEnumerable wo IEnumerable<(WorkloadDefinition workload, WorkloadManifest workloadManifest)> EnumerateWorkloadWithExtendsRec(WorkloadId workloadId, IEnumerable extends, WorkloadManifest? manifest) { + InitializeManifests(); dedup ??= new HashSet { workloadId }; foreach (var baseWorkloadId in extends) @@ -482,6 +495,7 @@ public IEnumerable GetExtendedWorkloads(IEnumerable wo throw new ArgumentException($"'{nameof(packId)}' cannot be null or empty", nameof(packId)); } + InitializeManifests(); if (_packs.TryGetValue(packId) is (WorkloadPack pack, _)) { if (ResolvePackPath(pack, out WorkloadPackId resolvedPackageId, out bool isInstalled) is string aliasedPath) @@ -501,6 +515,7 @@ public IEnumerable GetExtendedWorkloads(IEnumerable wo /// public ISet? GetWorkloadSuggestionForMissingPacks(IList packIds, out ISet unsatisfiablePacks) { + InitializeManifests(); var requestedPacks = new HashSet(packIds); var availableWorkloads = GetAvailableWorkloadDefinitions(); @@ -540,6 +555,7 @@ public IEnumerable GetAvailableWorkloads() private IEnumerable<(WorkloadDefinition workload, WorkloadManifest manifest)> GetAvailableWorkloadDefinitions() { + InitializeManifests(); foreach ((WorkloadId _, (WorkloadDefinition workload, WorkloadManifest manifest)) in _workloads) { if (!workload.IsAbstract && IsWorkloadPlatformCompatible(workload, manifest) && !IsWorkloadImplicitlyAbstract(workload, manifest)) @@ -557,6 +573,7 @@ public IEnumerable GetAvailableWorkloads() /// public IEnumerable GetUpdatedWorkloads(WorkloadResolver advertisingManifestResolver, IEnumerable installedWorkloads) { + InitializeManifests(); foreach (var workloadId in installedWorkloads) { if (!_workloads.ContainsKey(workloadId) || !advertisingManifestResolver._workloads.ContainsKey(workloadId)) @@ -608,11 +625,14 @@ private bool PackHasChanged(WorkloadPack oldPack, WorkloadPack newPack) /// ArgumentNullException public WorkloadManifest GetManifestFromWorkload(WorkloadId workloadId) { + InitializeManifests(); return _workloads[workloadId].manifest; } public WorkloadResolver CreateOverlayResolver(IWorkloadManifestProvider overlayManifestProvider) { + InitializeManifests(); + // we specifically don't assign the overlayManifestProvider to the new resolver // because it's not possible to refresh an overlay resolver var overlayResolver = new WorkloadResolver(_dotnetRootPaths, _currentRuntimeIdentifiers, GetSdkFeatureBand()); @@ -627,6 +647,9 @@ public WorkloadResolver CreateOverlayResolver(IWorkloadManifestProvider overlayM overlayResolver.ComposeWorkloadManifests(); + // Because we're injecting additional manifests, InitializeManifests isn't used for the overlay resolver + overlayResolver._initializedManifests = true; + return overlayResolver; } @@ -696,6 +719,7 @@ public WorkloadInfo(WorkloadId id, string? description) public WorkloadInfo GetWorkloadInfo(WorkloadId workloadId) { + InitializeManifests(); if (_workloads.TryGetValue(workloadId) is not (WorkloadDefinition workload, _)) { throw new ArgumentException($"Workload '{workloadId}' not found", nameof(workloadId)); @@ -705,6 +729,7 @@ public WorkloadInfo GetWorkloadInfo(WorkloadId workloadId) public bool IsPlatformIncompatibleWorkload(WorkloadId workloadId) { + InitializeManifests(); if (_workloads.TryGetValue(workloadId) is not (WorkloadDefinition workload, WorkloadManifest manifest)) { // Not a recognized workload @@ -721,6 +746,7 @@ private bool IsWorkloadPlatformCompatible(WorkloadDefinition workload, WorkloadM public string GetManifestVersion(string manifestId) { + InitializeManifests(); if (_manifests.TryGetValue(manifestId, out var value)) { return value.manifest.Version; @@ -728,7 +754,11 @@ public string GetManifestVersion(string manifestId) throw new Exception($"Manifest with id {manifestId} does not exist."); } - public IEnumerable GetInstalledManifests() => _manifests.Select(t => t.Value.info); + public IEnumerable GetInstalledManifests() + { + InitializeManifests(); + return _manifests.Select(t => t.Value.info); + } private class EmptyWorkloadManifestProvider : IWorkloadManifestProvider { diff --git a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs index bbef970d5fd6..48c65e70846f 100644 --- a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs +++ b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs @@ -179,7 +179,9 @@ static string MakeManifest(string version, params (string id, string version)[] { "AAA", MakeManifest("20.0.0", ("BBB", "5.0.0"), ("CCC", "63.0.0"), ("DDD", "25.0.0")) } }; - var missingManifestEx = Assert.Throws(() => WorkloadResolver.CreateForTests(missingManifestProvider, fakeRootPath)); + var missingManifestResolver = WorkloadResolver.CreateForTests(missingManifestProvider, fakeRootPath); + + var missingManifestEx = Assert.Throws(() => missingManifestResolver.GetAvailableWorkloads().ToList()); Assert.StartsWith("Did not find workload manifest dependency 'BBB' required by manifest 'AAA'", missingManifestEx.Message); var inconsistentManifestProvider = new InMemoryFakeManifestProvider @@ -190,7 +192,8 @@ static string MakeManifest(string version, params (string id, string version)[] { "DDD", MakeManifest("30.0.0") }, }; - var inconsistentManifestEx = Assert.Throws(() => WorkloadResolver.CreateForTests(inconsistentManifestProvider, fakeRootPath)); + var inconsistentManifestResolver = WorkloadResolver.CreateForTests(inconsistentManifestProvider, fakeRootPath); + var inconsistentManifestEx = Assert.Throws(() => inconsistentManifestResolver.GetAvailableWorkloads().ToList()); Assert.StartsWith("Workload manifest dependency 'DDD' version '30.0.0' is lower than version '39.0.0' required by manifest 'BBB'", inconsistentManifestEx.Message); } diff --git a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/SdkDirectoryWorkloadManifestProviderTests.cs b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/SdkDirectoryWorkloadManifestProviderTests.cs index 44bf3f961184..2c78771b8838 100644 --- a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/SdkDirectoryWorkloadManifestProviderTests.cs +++ b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/SdkDirectoryWorkloadManifestProviderTests.cs @@ -552,7 +552,8 @@ public void ItFailsIfWorkloadSetFromGlobalJsonIsNotInstalled() } """); - var ex = Assert.Throws(() => new SdkDirectoryWorkloadManifestProvider(sdkRootPath: _fakeDotnetRootDirectory, sdkVersion: "8.0.200", userProfileDir: null, globalJsonPath: globalJsonPath)); + var manifestProvider = new SdkDirectoryWorkloadManifestProvider(sdkRootPath: _fakeDotnetRootDirectory, sdkVersion: "8.0.200", userProfileDir: null, globalJsonPath: globalJsonPath); + var ex = Assert.Throws(() => manifestProvider.GetManifests()); ex.Message.Should().Be(string.Format(Strings.WorkloadVersionFromGlobalJsonNotFound, "8.0.201", globalJsonPath)); } diff --git a/src/Tests/dotnet-workload-install.Tests/GivenDotnetWorkloadInstall.cs b/src/Tests/dotnet-workload-install.Tests/GivenDotnetWorkloadInstall.cs index 476a5f49894c..ac2f2c199f50 100644 --- a/src/Tests/dotnet-workload-install.Tests/GivenDotnetWorkloadInstall.cs +++ b/src/Tests/dotnet-workload-install.Tests/GivenDotnetWorkloadInstall.cs @@ -326,9 +326,11 @@ public void GivenWorkloadInstallItErrorsOnUnsupportedPlatform() var parseResult = Parser.Instance.Parse(new string[] { "dotnet", "workload", "install", mockWorkloadId }); var workloadResolverFactory = new MockWorkloadResolverFactory(dotnetRoot, "6.0.100", workloadResolver, userProfileDir: testDirectory); - var exceptionThrown = Assert.Throws(() => new WorkloadInstallCommand(parseResult, reporter: _reporter, workloadResolverFactory, workloadInstaller: installer, - nugetPackageDownloader: nugetDownloader, workloadManifestUpdater: manifestUpdater)); - exceptionThrown.Message.Should().Be(String.Format(Workloads.Workload.Install.LocalizableStrings.WorkloadNotSupportedOnPlatform, mockWorkloadId)); + var command = new WorkloadInstallCommand(parseResult, reporter: _reporter, workloadResolverFactory, workloadInstaller: installer, + nugetPackageDownloader: nugetDownloader, workloadManifestUpdater: manifestUpdater); + + var exceptionThrown = Assert.Throws(() => command.Execute()); + exceptionThrown.Message.Should().Be(String.Format(Workloads.Workload.Install.LocalizableStrings.WorkloadInstallationFailed, String.Format(Workloads.Workload.Install.LocalizableStrings.WorkloadNotSupportedOnPlatform, mockWorkloadId))); } [Theory]