diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadSetTests.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadSetTests.cs index 883d16d31d3..4815c41fe2c 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadSetTests.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadSetTests.cs @@ -57,6 +57,9 @@ public static void ItCanCreateWorkloadSets() 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)); diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/SwixPackageTests.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/SwixPackageTests.cs index 418915721ea..99b98e1b112 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/SwixPackageTests.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/SwixPackageTests.cs @@ -35,12 +35,12 @@ public void ItThrowsIfPackageRelativePathExceedsLimit() Assert.Equal(@"Relative package path exceeds the maximum length (182): Microsoft.NET.Workload.Mono.ToolChain.Manifest-6.0.100,version=6.0.0.0,chip=x64,productarch=neutral,machinearch=x64\Microsoft.NET.Workload.Mono.ToolChain.Manifest-6.0.100.6.0.0-preview.7.21377.12-x64.msi.", e.Message); } - [WindowsOnlyTheory] - [InlineData("16.0.527")] - public void ItOnlyIncludesDefinedPropertiesForMsiPackages(string packageVersion) + [WindowsOnlyFact] + public void ItOnlyIncludesDefinedPropertiesForMsiPackages() { // Build to a different path to avoid any file read locks on the MSI from other tests // that can open it. + string packageVersion = "16.0.527"; string PackageRootDirectory = Path.Combine(BaseIntermediateOutputPath, Path.GetRandomFileName()); string packagePath = Path.Combine(TestAssetsPath, $"microsoft.ios.templates.{packageVersion}.nupkg"); diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/CreateVisualStudioWorkloadSet.wix.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/CreateVisualStudioWorkloadSet.wix.cs index 93acbc1db7f..97ea915591e 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/CreateVisualStudioWorkloadSet.wix.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/CreateVisualStudioWorkloadSet.wix.cs @@ -95,14 +95,11 @@ protected override bool ExecuteCore() } }); - _ = Parallel.ForEach(swixPackageGroups, swixPackageGroup => + foreach (var swixPackageGroup in swixPackageGroups) { - lock (swixProjectItems) - { - swixProjectItems.Add(PackageGroupSwixProject.CreateProjectItem(swixPackageGroup, BaseIntermediateOutputPath, BaseOutputPath, - DefaultValues.PackageTypeWorkloadSetPackageGroup)); - } - }); + swixProjectItems.Add(PackageGroupSwixProject.CreateProjectItem(swixPackageGroup, BaseIntermediateOutputPath, BaseOutputPath, + DefaultValues.PackageTypeWorkloadSetPackageGroup)); + } } Msis = msiItems.ToArray(); diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/Msi/MsiUtils.wix.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/Msi/MsiUtils.wix.cs index 47bcfe2841f..4e7d29f738b 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/Msi/MsiUtils.wix.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/Msi/MsiUtils.wix.cs @@ -206,5 +206,19 @@ public static void ValidateProductVersion(Version version) throw new ArgumentOutOfRangeException(string.Format(Strings.MsiProductVersionOutOfRange, nameof(version.Build), ushort.MaxValue)); } } + + /// + /// Determines if the MSI contains a specific table. + /// + /// The path to the MSI package. + /// The name of the table. + /// if the table exists; otherwise. + public static bool HasTable(string packagePath, string tableName) + { + using InstallPackage ip = new(packagePath, DatabaseOpenMode.ReadOnly); + using Database db = new(packagePath, DatabaseOpenMode.ReadOnly); + + return db.Tables.Contains(tableName); + } } } diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/WorkloadSetProduct.wxs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/WorkloadSetProduct.wxs index ee77df5f773..01429f57ff6 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/WorkloadSetProduct.wxs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/MsiTemplate/WorkloadSetProduct.wxs @@ -7,22 +7,6 @@ - - - - - - - - - - - - - - NOT WIX_DOWNGRADE_DETECTED - -