Skip to content

Commit 994d138

Browse files
authored
[automated] Merge branch 'release/8.0.4xx' => 'main' (#42205)
2 parents db3abee + 7436542 commit 994d138

File tree

5 files changed

+89
-29
lines changed

5 files changed

+89
-29
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
@@ -147,7 +147,6 @@ public override int Execute()
147147
Reporter.WriteLine(string.Format(LocalizableStrings.WorkloadAlreadyInstalled, string.Join(" ", previouslyInstalledWorkloads)).Yellow());
148148
}
149149
workloadIds = workloadIds.Concat(installedWorkloads).Distinct();
150-
workloadIds = WriteSDKInstallRecordsForVSWorkloads(workloadIds);
151150

152151
if (!_skipManifestUpdate)
153152
{
@@ -174,6 +173,10 @@ public override int Execute()
174173
}
175174
UpdateWorkloadManifests(context, offlineCache);
176175
}
176+
177+
// This depends on getting the available workloads, so it needs to run after manifests hae potentially been installed
178+
workloadIds = WriteSDKInstallRecordsForVSWorkloads(workloadIds);
179+
177180
_workloadInstaller.InstallWorkloads(workloadIds, _sdkFeatureBand, context, offlineCache);
178181

179182
// 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
@@ -100,13 +100,17 @@ public override int Execute()
100100
Reporter.WriteLine();
101101
try
102102
{
103-
var workloadIds = WriteSDKInstallRecordsForVSWorkloads(GetUpdatableWorkloads());
103+
IEnumerable<WorkloadId> workloadIds = Enumerable.Empty<WorkloadId>();
104104

105105
DirectoryPath? offlineCache = string.IsNullOrWhiteSpace(_fromCacheOption) ? null : new DirectoryPath(_fromCacheOption);
106106

107107
RunInNewTransaction(context =>
108108
{
109109
UpdateWorkloadManifests(context, offlineCache);
110+
111+
// This depends on getting the available workloads, so it needs to run after manifests hae potentially been installed
112+
workloadIds = WriteSDKInstallRecordsForVSWorkloads(GetUpdatableWorkloads());
113+
110114
_workloadInstaller.InstallWorkloads(workloadIds, _sdkFeatureBand, context, offlineCache);
111115
});
112116

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ protected void InstallSdk(bool deployStage2 = true)
6868

6969
VM.CreateRunCommand($@"c:\SdkTesting\{SdkInstallerFileName}", "/quiet")
7070
.WithDescription($"Install SDK {SdkInstallerVersion}")
71-
.Execute()
72-
.Should()
73-
.Pass();
71+
.Execute().Should().Pass();
72+
73+
7474

7575
if (deployStage2)
7676
{
@@ -94,6 +94,27 @@ protected void DeployStage2Sdk()
9494
return;
9595
}
9696

97+
98+
// Install any runtimes that are in the c:\SdkTesting directory, to support using older baseline SDK versions with a newer stage 2
99+
var sdkTestingDir = VM.GetRemoteDirectory(@"c:\SdkTesting");
100+
List<string> runtimeInstallers = new List<string>();
101+
string installerPrefix = "dotnet-runtime-";
102+
string installerSuffix = "-win-x64.exe";
103+
foreach (var file in sdkTestingDir.Files.Select(Path.GetFileName))
104+
{
105+
if (file.StartsWith(installerPrefix) && file.EndsWith(installerSuffix))
106+
{
107+
runtimeInstallers.Add(file);
108+
}
109+
}
110+
111+
if (runtimeInstallers.Any())
112+
{
113+
VM.CreateActionGroup($"Install .NET runtime(s)",
114+
runtimeInstallers.Select(i => VM.CreateRunCommand($@"c:\SdkTesting\{i}", "/quiet")).ToArray())
115+
.Execute().Should().Pass();
116+
}
117+
97118
var result = VM.CreateRunCommand("dotnet", "--version")
98119
.WithIsReadOnly(true)
99120
.Execute();

test/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();

test/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Linq;
88
using System.Text;
9+
using System.Text.Json;
910
using System.Threading.Tasks;
1011
using Microsoft.DotNet.MsiInstallerTests.Framework;
1112
using Microsoft.NET.Sdk.WorkloadManifestReader;
@@ -17,8 +18,24 @@ public class WorkloadSetTests : VMTestBase
1718
{
1819
readonly string SdkTestingDirectory = @"C:\SdkTesting";
1920

21+
22+
Lazy<Dictionary<string, string>> _testWorkloadSetVersions;
23+
string WorkloadSetVersion1 => _testWorkloadSetVersions.Value.GetValueOrDefault("version1", "8.0.300-preview.0.24178.1");
24+
string WorkloadSetVersion2 => _testWorkloadSetVersions.Value.GetValueOrDefault("version2", "8.0.300-preview.0.24217.2");
25+
string WorkloadSetPreviousBandVersion => _testWorkloadSetVersions.Value.GetValueOrDefault("previousbandversion", "8.0.204");
26+
2027
public WorkloadSetTests(ITestOutputHelper log) : base(log)
2128
{
29+
_testWorkloadSetVersions = new Lazy<Dictionary<string, string>>(() =>
30+
{
31+
var versionsFile = VM.GetRemoteFile(@"c:\SdkTesting\workloadsets\testworkloadsetversions.json");
32+
if (!versionsFile.Exists)
33+
{
34+
return new Dictionary<string, string>();
35+
}
36+
37+
return JsonSerializer.Deserialize<Dictionary<string, string>>(versionsFile.ReadAllText());
38+
});
2239
}
2340

2441
[Fact]
@@ -91,7 +108,7 @@ public void UpdateWithWorkloadSets()
91108

92109
newRollback.ManifestVersions.Should().NotBeEquivalentTo(rollbackAfterUpdate.ManifestVersions);
93110

94-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24217.2");
111+
GetWorkloadVersion().Should().Be(WorkloadSetVersion2);
95112
}
96113

97114
[Fact]
@@ -113,10 +130,19 @@ public void UpdateInWorkloadSetModeWithNoAvailableWorkloadSet()
113130
GetWorkloadVersion().Should().Be(updatedWorkloadVersion);
114131
}
115132

116-
[Theory]
117-
[InlineData("8.0.300-preview.0.24178.1")]
118-
[InlineData("8.0.204")]
119-
public void UpdateToSpecificWorkloadSetVersion(string versionToInstall)
133+
[Fact]
134+
public void UpdateToSpecificWorkloadSetVersion()
135+
{
136+
UpdateToWorkloadSetVersion(WorkloadSetVersion1);
137+
}
138+
139+
[Fact]
140+
public void UpdateToPreviousBandWorkloadSetVersion()
141+
{
142+
UpdateToWorkloadSetVersion(WorkloadSetPreviousBandVersion);
143+
}
144+
145+
private void UpdateToWorkloadSetVersion(string versionToInstall)
120146
{
121147
InstallSdk();
122148

@@ -148,7 +174,7 @@ public void UpdateToSpecificWorkloadSetVersion(string versionToInstall)
148174
.Should()
149175
.Pass();
150176

151-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24217.2");
177+
GetWorkloadVersion().Should().Be(WorkloadSetVersion2);
152178
}
153179

154180
[Fact]
@@ -189,8 +215,7 @@ public void UpdateWorkloadSetWithoutAvailableManifests()
189215
VM.CreateRunCommand("dotnet", "workload", "update", "--source", @"c:\SdkTesting\workloadsets")
190216
.Execute()
191217
.Should()
192-
.Pass()
193-
.And.HaveStdOutContaining("No workload update found");
218+
.Fail();
194219

195220
VM.CreateRunCommand("dotnet", "workload", "search")
196221
.WithIsReadOnly(true)
@@ -208,7 +233,7 @@ public void UpdateToWorkloadSetVersionWithManifestsNotAvailable()
208233

209234
var workloadVersionBeforeUpdate = GetWorkloadVersion();
210235

211-
VM.CreateRunCommand("dotnet", "workload", "update", "--version", @"8.0.300-preview.0.24217.2", "--source", @"c:\SdkTesting\workloadsets")
236+
VM.CreateRunCommand("dotnet", "workload", "update", "--version", WorkloadSetVersion2, "--source", @"c:\SdkTesting\workloadsets")
212237
.Execute()
213238
.Should()
214239
.Fail();
@@ -226,7 +251,7 @@ void SetupWorkloadSetInGlobalJson(out WorkloadSet originalRollback)
226251
{
227252
InstallSdk();
228253

229-
var versionToUpdateTo = "8.0.300-preview.0.24217.2";
254+
var versionToUpdateTo = WorkloadSetVersion2;
230255

231256
string originalVersion = GetWorkloadVersion();
232257

@@ -287,7 +312,7 @@ public void InstallWithVersionAndSkipManifestUpdate()
287312
{
288313
InstallSdk();
289314

290-
VM.CreateRunCommand("dotnet", "workload", "install", "aspire", "--skip-manifest-update", "--version", "8.0.300-preview.0.24178.1")
315+
VM.CreateRunCommand("dotnet", "workload", "install", "aspire", "--skip-manifest-update", "--version", WorkloadSetVersion1)
291316
.Execute().Should().Fail()
292317
.And.HaveStdErrContaining("--skip-manifest-update")
293318
.And.HaveStdErrContaining("--sdk-version");
@@ -301,17 +326,17 @@ public void InstallWithVersionWhenPinned()
301326
AddNuGetSource(@"c:\SdkTesting\WorkloadSets");
302327

303328
string originalVersion = GetWorkloadVersion();
304-
originalVersion.Should().NotBe("8.0.300-preview.0.24178.1");
329+
originalVersion.Should().NotBe(WorkloadSetVersion1);
305330

306-
VM.CreateRunCommand("dotnet", "workload", "update", "--version", "8.0.300-preview.0.24178.1")
331+
VM.CreateRunCommand("dotnet", "workload", "update", "--version", WorkloadSetVersion1)
307332
.Execute().Should().Pass();
308333

309-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24178.1");
334+
GetWorkloadVersion().Should().Be(WorkloadSetVersion1);
310335

311-
VM.CreateRunCommand("dotnet", "workload", "install", "aspire", "--version", "8.0.300-preview.0.24217.2")
336+
VM.CreateRunCommand("dotnet", "workload", "install", "aspire", "--version", WorkloadSetVersion2)
312337
.Execute().Should().Pass();
313338

314-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24217.2");
339+
GetWorkloadVersion().Should().Be(WorkloadSetVersion2);
315340
}
316341

317342
[Fact]
@@ -322,18 +347,18 @@ public void InstallWithGlobalJsonWhenPinned()
322347
//AddNuGetSource(@"c:\SdkTesting\WorkloadSets");
323348

324349
string originalVersion = GetWorkloadVersion();
325-
originalVersion.Should().NotBe("8.0.300-preview.0.24178.1");
350+
originalVersion.Should().NotBe(WorkloadSetVersion1);
326351

327-
VM.CreateRunCommand("dotnet", "workload", "update", "--version", "8.0.300-preview.0.24178.1")
352+
VM.CreateRunCommand("dotnet", "workload", "update", "--version", WorkloadSetVersion1)
328353
.Execute().Should().Pass();
329354

330-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24178.1");
355+
GetWorkloadVersion().Should().Be(WorkloadSetVersion1);
331356

332357
VM.CreateRunCommand("dotnet", "workload", "install", "aspire")
333358
.WithWorkingDirectory(SdkTestingDirectory)
334359
.Execute().Should().Pass();
335360

336-
GetWorkloadVersion(SdkTestingDirectory).Should().Be("8.0.300-preview.0.24217.2");
361+
GetWorkloadVersion(SdkTestingDirectory).Should().Be(WorkloadSetVersion2);
337362

338363
GetRollback(SdkTestingDirectory).Should().NotBe(originalRollback);
339364

@@ -347,22 +372,28 @@ public void UpdateShouldNotPinWorkloadSet()
347372

348373
AddNuGetSource(@"c:\SdkTesting\WorkloadSets");
349374

375+
var packageVersion = WorkloadSet.WorkloadSetVersionToWorkloadSetPackageVersion(WorkloadSetVersion2, out var sdkFeatureBand);
376+
350377
// Rename latest workload set so it won't be installed
351-
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.nupkg", $"Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.bak")
378+
VM.CreateActionGroup($"Disable {WorkloadSetVersion2}",
379+
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.{sdkFeatureBand}.{packageVersion}.nupkg", $"Microsoft.NET.Workloads.{sdkFeatureBand}.{packageVersion}.bak"),
380+
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.{sdkFeatureBand}.*.{packageVersion}.nupkg", $"Microsoft.NET.Workloads.{sdkFeatureBand}.*.{packageVersion}.bak"))
352381
.Execute().Should().Pass();
353382

354383
VM.CreateRunCommand("dotnet", "workload", "update")
355384
.Execute().Should().Pass();
356385

357-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24178.1");
386+
GetWorkloadVersion().Should().Be(WorkloadSetVersion1);
358387

359388
// Bring latest workload set version back, so installing workload should update to it
360-
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.bak", $"Microsoft.NET.Workloads.8.0.300-preview.*.24217.2.nupkg")
389+
VM.CreateActionGroup($"Enable {WorkloadSetVersion2}",
390+
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.{sdkFeatureBand}.{packageVersion}.bak", $"Microsoft.NET.Workloads.{sdkFeatureBand}.{packageVersion}.nupkg"),
391+
VM.CreateRunCommand("cmd", "/c", "ren", @$"c:\SdkTesting\WorkloadSets\Microsoft.NET.Workloads.{sdkFeatureBand}.*.{packageVersion}.bak", $"Microsoft.NET.Workloads.{sdkFeatureBand}.*.{packageVersion}.nupkg"))
361392
.Execute().Should().Pass();
362393

363394
InstallWorkload("aspire", skipManifestUpdate: false);
364395

365-
GetWorkloadVersion().Should().Be("8.0.300-preview.0.24217.2");
396+
GetWorkloadVersion().Should().Be(WorkloadSetVersion2);
366397
}
367398

368399
[Fact]

0 commit comments

Comments
 (0)