Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
joeloff committed Oct 16, 2023
1 parent 7433afa commit f79ad7d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 14 additions & 0 deletions src/Microsoft.DotNet.Build.Tasks.Workloads/src/Msi/MsiUtils.wix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,19 @@ public static void ValidateProductVersion(Version version)
throw new ArgumentOutOfRangeException(string.Format(Strings.MsiProductVersionOutOfRange, nameof(version.Build), ushort.MaxValue));
}
}

/// <summary>
/// Determines if the MSI contains a specific table.
/// </summary>
/// <param name="packagePath">The path to the MSI package.</param>
/// <param name="tableName">The name of the table.</param>
/// <returns><see langword="true"/> if the table exists; <see langword="false"/> otherwise.</returns>
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@

<Package InstallerVersion="$(var.InstallerVersion)" Compressed="yes" InstallScope="perMachine" />

<!-- MajorUpgrade element doesn't support setting the language attribute in the upgrade table -->
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Maximum="$(var.ProductVersion)" MigrateFeatures="yes" IncludeMinimum="no" Property="WIX_UPGRADE_DETECTED" />
<UpgradeVersion Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" Property="WIX_DOWNGRADE_DETECTED" />
</Upgrade>

<!-- The new MSI is installed before the older version is removed. This is the fastest upgrade option. -->
<InstallExecuteSequence>
<!-- See https://docs.microsoft.com/en-us/windows/win32/msi/removeexistingproducts-action for other options -->
<RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>

<Condition Message="A newer version of [ProductName] is alread installed.">
NOT WIX_DOWNGRADE_DETECTED
</Condition>

<?if $(var.Platform)~=x64?>
<CustomActionRef Id="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" />
<?endif?>
Expand Down

0 comments on commit f79ad7d

Please sign in to comment.