Skip to content

Commit 979ac00

Browse files
committed
Fix combinations of workload install, global install state, and global.json or command-line specified workload set version
1 parent 62c9743 commit 979ac00

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ public override int Execute()
147147
{
148148
var installStateFilePath = Path.Combine(WorkloadInstallType.GetInstallStateFolder(_sdkFeatureBand, _dotnetPath), "default.json");
149149
if (string.IsNullOrWhiteSpace(_fromRollbackDefinition) &&
150+
!SpecifiedWorkloadSetVersionOnCommandLine &&
151+
!SpecifiedWorkloadSetVersionInGlobalJson &&
150152
InstallStateContents.FromPath(installStateFilePath) is InstallStateContents installState &&
151153
(installState.Manifests != null || installState.WorkloadVersion != null))
152154
{

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ void SetupWorkloadSetInGlobalJson(out WorkloadSet originalRollback)
247247
result.StdErr.Should().Contain(versionToUpdateTo);
248248

249249
AddNuGetSource(@"C:\SdkTesting\workloadsets", SdkTestingDirectory);
250-
251250
}
252251

253252
[Fact]
@@ -294,6 +293,52 @@ public void InstallWithVersionAndSkipManifestUpdate()
294293
.And.HaveStdErrContaining("--sdk-version");
295294
}
296295

296+
[Fact]
297+
public void InstallWithVersionWhenPinned()
298+
{
299+
InstallSdk();
300+
301+
AddNuGetSource(@"c:\SdkTesting\WorkloadSets");
302+
303+
string originalVersion = GetWorkloadVersion();
304+
originalVersion.Should().NotBe("8.0.300-preview.0.24178.1");
305+
306+
VM.CreateRunCommand("dotnet", "workload", "update", "--version", "8.0.300-preview.0.24178.1")
307+
.Execute().Should().Pass();
308+
309+
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24178.1");
310+
311+
VM.CreateRunCommand("dotnet", "workload", "install", "aspire", "--version", "8.0.300-preview.0.24217.2")
312+
.Execute().Should().Pass();
313+
314+
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24217.2");
315+
}
316+
317+
[Fact]
318+
public void InstallWithGlobalJsonWhenPinned()
319+
{
320+
SetupWorkloadSetInGlobalJson(out var originalRollback);
321+
322+
//AddNuGetSource(@"c:\SdkTesting\WorkloadSets");
323+
324+
string originalVersion = GetWorkloadVersion();
325+
originalVersion.Should().NotBe("8.0.300-preview.0.24178.1");
326+
327+
VM.CreateRunCommand("dotnet", "workload", "update", "--version", "8.0.300-preview.0.24178.1")
328+
.Execute().Should().Pass();
329+
330+
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24178.1");
331+
332+
VM.CreateRunCommand("dotnet", "workload", "install", "aspire")
333+
.WithWorkingDirectory(SdkTestingDirectory)
334+
.Execute().Should().Pass();
335+
336+
GetWorkloadVersion(SdkTestingDirectory).Should().Be("8.0.300-preview.0.24217.2");
337+
338+
GetRollback(SdkTestingDirectory).Should().NotBe(originalRollback);
339+
340+
}
341+
297342
[Fact]
298343
public void UpdateShouldNotPinWorkloadSet()
299344
{

0 commit comments

Comments
 (0)