diff --git a/eng/Versions.props b/eng/Versions.props
index c43d67ed817..da4fe8a88af 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -51,11 +51,15 @@
6.0.4
6.0.4
6.0.4
+ 9.0.100-baseline.1.23464.1
6.0.4
8.0.0-preview.6.23326.2
6.0.3
6.0.4
+ 6.0.21
+ 6.0.22
15.2.302-preview.14.122
+ 16.0.527
7.0.0
8.0.0-preview.4.23259.5
diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadSetTests.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadSetTests.cs
new file mode 100644
index 00000000000..4815c41fe2c
--- /dev/null
+++ b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadSetTests.cs
@@ -0,0 +1,83 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.IO;
+using System.Linq;
+using FluentAssertions;
+using Microsoft.Arcade.Test.Common;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+using Microsoft.DotNet.Build.Tasks.Workloads.Msi;
+using Xunit;
+
+namespace Microsoft.DotNet.Build.Tasks.Workloads.Tests
+{
+ public class CreateVisualStudioWorkloadSetTests : TestBase
+ {
+ [WindowsOnlyFact]
+ public static void ItCanCreateWorkloadSets()
+ {
+ // Create intermediate outputs under %temp% to avoid path issues and make sure it's clean so we don't pick up
+ // conflicting sources from previous runs.
+ string baseIntermediateOutputPath = Path.Combine(Path.GetTempPath(), "WLS");
+
+ if (Directory.Exists(baseIntermediateOutputPath))
+ {
+ Directory.Delete(baseIntermediateOutputPath, recursive: true);
+ }
+
+ ITaskItem[] workloadSetPackages = new[]
+ {
+ new TaskItem(Path.Combine(TestAssetsPath, "microsoft.net.workloads.9.0.100.9.0.100-baseline.1.23464.1.nupkg"))
+ .WithMetadata(Metadata.MsiVersion, "12.8.45")
+ };
+
+ IBuildEngine buildEngine = new MockBuildEngine();
+
+ CreateVisualStudioWorkloadSet createWorkloadSetTask = new CreateVisualStudioWorkloadSet()
+ {
+ BaseOutputPath = BaseOutputPath,
+ BaseIntermediateOutputPath = baseIntermediateOutputPath,
+ BuildEngine = buildEngine,
+ PackageSource = TestAssetsPath,
+ WixToolsetPath = WixToolsetPath,
+ WorkloadSetPackageFiles = workloadSetPackages
+ };
+
+ Assert.True(createWorkloadSetTask.Execute());
+
+ // Spot check the x64 generated MSI.
+ ITaskItem msi = createWorkloadSetTask.Msis.Where(i => i.GetMetadata(Metadata.Platform) == "x64").FirstOrDefault();
+ Assert.NotNull(msi);
+
+ // Verify the workload set records the CLI will use.
+ MsiUtils.GetAllRegistryKeys(msi.ItemSpec).Should().Contain(r =>
+ r.Root == 2 &&
+ r.Key == @"SOFTWARE\Microsoft\dotnet\InstalledWorkloadSets\x64\9.0.100\9.0.100-baseline.1.23464.1" &&
+ r.Name == "ProductVersion" &&
+ r.Value == "12.8.45");
+
+ // Workload sets are SxS. Verify that we don't have an Upgrade table.
+ Assert.False(MsiUtils.HasTable(msi.ItemSpec, "Upgrade"));
+
+ // Verify the SWIX authoring for one of the workload set MSIs.
+ ITaskItem workloadSetSwixItem = createWorkloadSetTask.SwixProjects.Where(s => s.ItemSpec.Contains(@"Microsoft.NET.Workloads.9.0.100.9.0.100-baseline.1.23464.1\x64")).FirstOrDefault();
+ Assert.Equal(DefaultValues.PackageTypeMsiWorkloadSet, workloadSetSwixItem.GetMetadata(Metadata.PackageType));
+
+ string msiSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(workloadSetSwixItem.ItemSpec), "msi.swr"));
+ Assert.Contains("package name=Microsoft.NET.Workloads.9.0.100.9.0.100-baseline.1.23464.1", msiSwr);
+ Assert.Contains("version=12.8.45", msiSwr);
+ Assert.DoesNotContain("vs.package.chip=x64", msiSwr);
+ Assert.Contains("vs.package.machineArch=x64", msiSwr);
+ Assert.Contains("vs.package.type=msi", msiSwr);
+
+ // Verify package group SWIX project
+ ITaskItem workloadSetPackageGroupSwixItem = createWorkloadSetTask.SwixProjects.Where(
+ s => s.GetMetadata(Metadata.PackageType).Equals(DefaultValues.PackageTypeWorkloadSetPackageGroup)).
+ FirstOrDefault();
+ string packageGroupSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(workloadSetPackageGroupSwixItem.ItemSpec), "packageGroup.swr"));
+ Assert.Contains("package name=PackageGroup.NET.Workloads-9.0.100", packageGroupSwr);
+ Assert.Contains("vs.dependency id=Microsoft.NET.Workloads.9.0.100.9.0.100-baseline.1.23464.1", packageGroupSwr);
+ }
+ }
+}
diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadTests.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadTests.cs
index cbdbe0e290a..e95fd0db6b2 100644
--- a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadTests.cs
+++ b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadTests.cs
@@ -15,6 +15,7 @@
namespace Microsoft.DotNet.Build.Tasks.Workloads.Tests
{
+ [Collection("Workload Creation")]
public class CreateVisualStudioWorkloadTests : TestBase
{
[WindowsOnlyFact]
diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/Microsoft.DotNet.Build.Tasks.Workloads.Tests.csproj b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/Microsoft.DotNet.Build.Tasks.Workloads.Tests.csproj
index db42e1a9fd7..72719b864a0 100644
--- a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/Microsoft.DotNet.Build.Tasks.Workloads.Tests.csproj
+++ b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/Microsoft.DotNet.Build.Tasks.Workloads.Tests.csproj
@@ -25,13 +25,15 @@
-
+
+
+
@@ -43,12 +45,16 @@
+
+
+
+
diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/MsiTests.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/MsiTests.cs
index a510b1cd94b..f17c0319469 100644
--- a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/MsiTests.cs
+++ b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/MsiTests.cs
@@ -104,8 +104,8 @@ public void ItCanBuildATemplatePackMsi()
WorkloadPack p = new(new WorkloadPackId("Microsoft.iOS.Templates"), "15.2.302-preview.14.122", WorkloadPackKind.Template, null);
TemplatePackPackage pkg = new(p, packagePath, new[] { "x64" }, PackageRootDirectory);
pkg.Extract();
- WorkloadPackMsi msi = new(pkg, "x64", new MockBuildEngine(), WixToolsetPath, BaseIntermediateOutputPath);
-
+ var buildEngine = new MockBuildEngine();
+ WorkloadPackMsi msi = new(pkg, "x64", buildEngine, WixToolsetPath, BaseIntermediateOutputPath);
ITaskItem item = msi.Build(MsiOutputPath);
string msiPath = item.GetMetadata(Metadata.FullPath);
diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/PackageTests.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/PackageTests.cs
index 579a0e66a28..1d626d57d35 100644
--- a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/PackageTests.cs
+++ b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/PackageTests.cs
@@ -2,15 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Xunit;
-using Microsoft.DotNet.Build.Tasks.Workloads;
+using System.IO;
+using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Deployment.DotNet.Releases;
-using System.IO;
+using Xunit;
namespace Microsoft.DotNet.Build.Tasks.Workloads.Tests
{
@@ -22,13 +18,35 @@ public void ItCanReadAManifestPackage()
{
string PackageRootDirectory = Path.Combine(BaseIntermediateOutputPath, "pkg");
- TaskItem manifestPackageItem = new(Path.Combine(TestAssetsPath, "microsoft.net.workload.mono.toolchain.manifest-6.0.200.6.0.3.nupkg"));
+ TaskItem manifestPackageItem = new(Path.Combine(TestAssetsPath, "microsoft.net.workload.mono.toolchain.manifest-6.0.300.6.0.22.nupkg"));
WorkloadManifestPackage p = new(manifestPackageItem, PackageRootDirectory, new Version("1.2.3"));
- ReleaseVersion expectedFeatureBand = new("6.0.200");
+ ReleaseVersion expectedFeatureBand = new("6.0.300");
Assert.Equal("Microsoft.NET.Workload.Mono.ToolChain", p.ManifestId);
Assert.Equal(expectedFeatureBand, p.SdkFeatureBand);
}
+
+ [WindowsOnlyTheory]
+ [InlineData("Microsoft.NET.Workload.Emscripten.net6.Manifest-8.0.100-alpha.1", WorkloadManifestPackage.ManifestSeparator, "8.0.100-alpha.1")]
+ [InlineData("Microsoft.NET.Workload.Emscripten.Manifest-8.0.100-alpha.1.23062.6", WorkloadManifestPackage.ManifestSeparator, "8.0.100-alpha.1.23062.6")]
+ [InlineData("Microsoft.NET.Workloads.8.0.100-preview.7.23376.3", WorkloadSetPackage.SdkFeatureBandSeparator, "8.0.100-preview.7.23376.3")]
+ [InlineData("Microsoft.NET.Workloads.8.0.100", WorkloadSetPackage.SdkFeatureBandSeparator, "8.0.100")]
+ public static void ItExtractsTheSdkVersionFromThePackageId(string packageId, string separator, string expectedVersion)
+ {
+ string actualSdkVersion = WorkloadPackageBase.GetSdkVersion(packageId, separator);
+
+ Assert.Equal(expectedVersion, actualSdkVersion);
+ }
+
+ [WindowsOnlyFact]
+ public void ItThrowsIfTheMsiVersionIsInvalid()
+ {
+ string PackageRootDirectory = Path.Combine(BaseIntermediateOutputPath, "wls-pkg");
+
+ ITaskItem workloadSetPackageItem = new TaskItem(Path.Combine(TestAssetsPath, "microsoft.net.workloads.9.0.100.9.0.100-baseline.1.23464.1.nupkg"));
+
+ Assert.Throws(() => { WorkloadSetPackage p = new(workloadSetPackageItem, PackageRootDirectory, new Version("256.12.3")); });
+ }
}
}
diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/SwixPackageGroupTests.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/SwixPackageGroupTests.cs
index 06aef31e000..e0a47e07da7 100644
--- a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/SwixPackageGroupTests.cs
+++ b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/SwixPackageGroupTests.cs
@@ -2,17 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Collections;
using System.Collections.Generic;
using System.IO;
-using Microsoft.Arcade.Test.Common;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
-using Microsoft.Deployment.DotNet.Releases;
-using Microsoft.DotNet.Build.Tasks.Workloads.Msi;
using Microsoft.DotNet.Build.Tasks.Workloads.Swix;
-using Microsoft.NET.Sdk.WorkloadManifestReader;
-using NuGet.Packaging.Core;
using Xunit;
namespace Microsoft.DotNet.Build.Tasks.Workloads.Tests
@@ -31,8 +25,9 @@ public void ItGeneratesPackageGroupsForManifestPackages(string manifestPackageFi
string destinationBaseDirectory = Path.Combine(BaseIntermediateOutputPath, destinationDirectory);
TaskItem manifestPackageItem = new(Path.Combine(TestAssetsPath, manifestPackageFilename));
WorkloadManifestPackage manifestPackage = new(manifestPackageItem, destinationBaseDirectory, msiVersion, shortNames, null, isSxS: true);
- var packageGroup = SwixPackageGroup.Create(manifestPackage);
- var packageGroupItem = PackageGroupSwixProject.CreateProjectItem(packageGroup, BaseIntermediateOutputPath, BaseOutputPath);
+ var packageGroup = new SwixPackageGroup(manifestPackage);
+ var packageGroupItem = PackageGroupSwixProject.CreateProjectItem(packageGroup, BaseIntermediateOutputPath, BaseOutputPath,
+ DefaultValues.PackageTypeManifestPackageGroup);
// Verify package group expectations
Assert.Equal(expectedPackageId, packageGroup.Name);
@@ -45,14 +40,14 @@ public void ItGeneratesPackageGroupsForManifestPackages(string manifestPackageFi
// Verify the task item metadata
Assert.Equal(expectedFeatureBand, packageGroupItem.GetMetadata(Metadata.SdkFeatureBand));
- Assert.Equal(DefaultValues.PackageTypePackageGroup, packageGroupItem.GetMetadata(Metadata.PackageType));
+ Assert.Equal(DefaultValues.PackageTypeManifestPackageGroup, packageGroupItem.GetMetadata(Metadata.PackageType));
}
public static readonly IEnumerable