diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs index 621c7c47d365..f722aefbe3a8 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs @@ -141,7 +141,6 @@ public override int Execute() Reporter.WriteLine(string.Format(LocalizableStrings.WorkloadAlreadyInstalled, string.Join(" ", previouslyInstalledWorkloads)).Yellow()); } workloadIds = workloadIds.Concat(installedWorkloads).Distinct(); - workloadIds = WriteSDKInstallRecordsForVSWorkloads(workloadIds); if (!_skipManifestUpdate) { @@ -168,6 +167,10 @@ public override int Execute() } UpdateWorkloadManifests(context, offlineCache); } + + // This depends on getting the available workloads, so it needs to run after manifests hae potentially been installed + workloadIds = WriteSDKInstallRecordsForVSWorkloads(workloadIds); + _workloadInstaller.InstallWorkloads(workloadIds, _sdkFeatureBand, context, offlineCache); // Write workload installation records diff --git a/src/Cli/dotnet/commands/dotnet-workload/update/WorkloadUpdateCommand.cs b/src/Cli/dotnet/commands/dotnet-workload/update/WorkloadUpdateCommand.cs index f340dcc83136..11086d14c710 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/update/WorkloadUpdateCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/update/WorkloadUpdateCommand.cs @@ -94,13 +94,17 @@ public override int Execute() Reporter.WriteLine(); try { - var workloadIds = WriteSDKInstallRecordsForVSWorkloads(GetUpdatableWorkloads()); + IEnumerable workloadIds = Enumerable.Empty(); DirectoryPath? offlineCache = string.IsNullOrWhiteSpace(_fromCacheOption) ? null : new DirectoryPath(_fromCacheOption); RunInNewTransaction(context => { UpdateWorkloadManifests(context, offlineCache); + + // This depends on getting the available workloads, so it needs to run after manifests hae potentially been installed + workloadIds = WriteSDKInstallRecordsForVSWorkloads(GetUpdatableWorkloads()); + _workloadInstaller.InstallWorkloads(workloadIds, _sdkFeatureBand, context, offlineCache); }); diff --git a/src/Tests/dotnet-MsiInstallation.Tests/Framework/VMTestBase.cs b/src/Tests/dotnet-MsiInstallation.Tests/Framework/VMTestBase.cs index 91f49bce6520..d53cf471be04 100644 --- a/src/Tests/dotnet-MsiInstallation.Tests/Framework/VMTestBase.cs +++ b/src/Tests/dotnet-MsiInstallation.Tests/Framework/VMTestBase.cs @@ -66,8 +66,23 @@ protected void InstallSdk(bool deployStage2 = true) .Should() .Pass(); - VM.CreateRunCommand($@"c:\SdkTesting\{SdkInstallerFileName}", "/quiet") - .WithDescription($"Install SDK {SdkInstallerVersion}") + var sdkTestingDir = VM.GetRemoteDirectory(@"c:\SdkTesting"); + List runtimeInstallers = new List(); + string installerPrefix = "dotnet-runtime-"; + string installerSuffix = "-win-x64.exe"; + foreach (var file in sdkTestingDir.Files.Select(Path.GetFileName)) + { + if (file.StartsWith(installerPrefix) && file.EndsWith(installerSuffix)) + { + runtimeInstallers.Add(file); + } + } + + VM.CreateActionGroup($"Install SDK {SdkInstallerVersion}", + [ + VM.CreateRunCommand($@"c:\SdkTesting\{SdkInstallerFileName}", "/quiet"), + ..runtimeInstallers.Select(i => VM.CreateRunCommand($@"c:\SdkTesting\{i}", "/quiet")) + ]) .Execute() .Should() .Pass(); diff --git a/src/Tests/dotnet-MsiInstallation.Tests/MsiInstallerTests.cs b/src/Tests/dotnet-MsiInstallation.Tests/MsiInstallerTests.cs index c557ba6ed856..213e5deb43db 100644 --- a/src/Tests/dotnet-MsiInstallation.Tests/MsiInstallerTests.cs +++ b/src/Tests/dotnet-MsiInstallation.Tests/MsiInstallerTests.cs @@ -137,6 +137,7 @@ public void SdkInstallation() } else { + // TODO: This doesn't work if we've installed additional runtimes to support the SDK VM.GetRemoteDirectory($@"c:\Program Files\dotnet") .Should() .NotExist(); diff --git a/src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs b/src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs index e580c8ad4d0f..109de42139aa 100644 --- a/src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs +++ b/src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs @@ -189,8 +189,7 @@ public void UpdateWorkloadSetWithoutAvailableManifests() VM.CreateRunCommand("dotnet", "workload", "update", "--source", @"c:\SdkTesting\workloadsets") .Execute() .Should() - .Pass() - .And.HaveStdOutContaining("No workload update found"); + .Fail(); VM.CreateRunCommand("dotnet", "workload", "search") .WithIsReadOnly(true)