Skip to content

Commit 4f75e80

Browse files
authored
Fix workload install or update with workload set specified in global.json (#41983)
2 parents c92695a + 84834e7 commit 4f75e80

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ public override int Execute()
141141
Reporter.WriteLine(string.Format(LocalizableStrings.WorkloadAlreadyInstalled, string.Join(" ", previouslyInstalledWorkloads)).Yellow());
142142
}
143143
workloadIds = workloadIds.Concat(installedWorkloads).Distinct();
144-
workloadIds = WriteSDKInstallRecordsForVSWorkloads(workloadIds);
145144

146145
if (!_skipManifestUpdate)
147146
{
@@ -168,6 +167,10 @@ public override int Execute()
168167
}
169168
UpdateWorkloadManifests(context, offlineCache);
170169
}
170+
171+
// This depends on getting the available workloads, so it needs to run after manifests hae potentially been installed
172+
workloadIds = WriteSDKInstallRecordsForVSWorkloads(workloadIds);
173+
171174
_workloadInstaller.InstallWorkloads(workloadIds, _sdkFeatureBand, context, offlineCache);
172175

173176
// Write workload installation records

src/Cli/dotnet/commands/dotnet-workload/update/WorkloadUpdateCommand.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,17 @@ public override int Execute()
9494
Reporter.WriteLine();
9595
try
9696
{
97-
var workloadIds = WriteSDKInstallRecordsForVSWorkloads(GetUpdatableWorkloads());
97+
IEnumerable<WorkloadId> workloadIds = Enumerable.Empty<WorkloadId>();
9898

9999
DirectoryPath? offlineCache = string.IsNullOrWhiteSpace(_fromCacheOption) ? null : new DirectoryPath(_fromCacheOption);
100100

101101
RunInNewTransaction(context =>
102102
{
103103
UpdateWorkloadManifests(context, offlineCache);
104+
105+
// This depends on getting the available workloads, so it needs to run after manifests hae potentially been installed
106+
workloadIds = WriteSDKInstallRecordsForVSWorkloads(GetUpdatableWorkloads());
107+
104108
_workloadInstaller.InstallWorkloads(workloadIds, _sdkFeatureBand, context, offlineCache);
105109
});
106110

src/Tests/dotnet-MsiInstallation.Tests/Framework/VMTestBase.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,23 @@ protected void InstallSdk(bool deployStage2 = true)
6666
.Should()
6767
.Pass();
6868

69-
VM.CreateRunCommand($@"c:\SdkTesting\{SdkInstallerFileName}", "/quiet")
70-
.WithDescription($"Install SDK {SdkInstallerVersion}")
69+
var sdkTestingDir = VM.GetRemoteDirectory(@"c:\SdkTesting");
70+
List<string> runtimeInstallers = new List<string>();
71+
string installerPrefix = "dotnet-runtime-";
72+
string installerSuffix = "-win-x64.exe";
73+
foreach (var file in sdkTestingDir.Files.Select(Path.GetFileName))
74+
{
75+
if (file.StartsWith(installerPrefix) && file.EndsWith(installerSuffix))
76+
{
77+
runtimeInstallers.Add(file);
78+
}
79+
}
80+
81+
VM.CreateActionGroup($"Install SDK {SdkInstallerVersion}",
82+
[
83+
VM.CreateRunCommand($@"c:\SdkTesting\{SdkInstallerFileName}", "/quiet"),
84+
..runtimeInstallers.Select(i => VM.CreateRunCommand($@"c:\SdkTesting\{i}", "/quiet"))
85+
])
7186
.Execute()
7287
.Should()
7388
.Pass();

src/Tests/dotnet-MsiInstallation.Tests/MsiInstallerTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public void SdkInstallation()
137137
}
138138
else
139139
{
140+
// TODO: This doesn't work if we've installed additional runtimes to support the SDK
140141
VM.GetRemoteDirectory($@"c:\Program Files\dotnet")
141142
.Should()
142143
.NotExist();

src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ public void UpdateWorkloadSetWithoutAvailableManifests()
189189
VM.CreateRunCommand("dotnet", "workload", "update", "--source", @"c:\SdkTesting\workloadsets")
190190
.Execute()
191191
.Should()
192-
.Pass()
193-
.And.HaveStdOutContaining("No workload update found");
192+
.Fail();
194193

195194
VM.CreateRunCommand("dotnet", "workload", "search")
196195
.WithIsReadOnly(true)

0 commit comments

Comments
 (0)