Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ tab_width = 2
indent_size = 4
tab_width = 4

# WiX files
[*.{wixproj,wxs,wxi,wxl,thm}]
indent_size = 2

# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
Expand Down
14 changes: 13 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,20 @@
<PackageVersion Include="Microsoft.OpenApi" Version="3.7.0" />
<PackageVersion Include="Microsoft.OpenApi.YamlReader" Version="3.7.0" />
<PackageVersion Include="Microsoft.Signed.Wix" Version="$(MicrosoftSignedWixVersion)" />
<PackageVersion Include="Microsoft.WixToolset.Sdk" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.OLE.Interop" Version="17.14.40260" />
<!-- This package is only used for workload tests and should not receive frequent updates. -->
Comment thread
joeloff marked this conversation as resolved.
<PackageVersion Include="Microsoft.VisualStudioEng.MicroBuild.Plugins.SwixBuild" Version="1.1.922" />
<PackageVersion Include="Microsoft.WixToolset.Heat" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.WixToolset.Dependency.wixext" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.WixToolset.Dtf.Compression" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.WixToolset.Dtf.Compression.Cab" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.WixToolset.Dtf.Resources" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.WixToolset.Dtf.WindowsInstaller" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.WixToolset.Dtf.WindowsInstaller.Package" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.WixToolset.Sdk" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.WixToolset.Util.wixext" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.WixToolset.UI.wixext" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Microsoft.Wix" Version="$(MicrosoftWixToolsetSdkVersion)" />
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="Octokit" Version="14.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<Source Uri="https://github.com/dotnet/dotnet" Mapping="arcade" Sha="1d4910780fe728cf5affade170fe51fc8f96f9fb" BarId="320053" />
<Source Uri="https://github.com/dotnet/dotnet" Mapping="arcade" Sha="1358fe9202089df7bdb79282a191c9dbbb773a06" BarId="320196" />
<ProductDependencies>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
2 changes: 2 additions & 0 deletions eng/common/native/NativeAotSupported.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<!-- Reject unsupported architectures via RID suffix match -->
<_NativeAotSupportedArch Condition="
'$(TargetArchitecture)' != 'wasm' and
'$(TargetArchitecture)' != 's390x' and
'$(TargetArchitecture)' != 'ppc64le' and
('$(TargetArchitecture)' != 'x86' or '$(TargetOS)' == 'windows')
">true</_NativeAotSupportedArch>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,77 +8,102 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.DotNet.Build.Tasks.Workloads.Msi;
using WixToolset.Dtf.WindowsInstaller;
using Xunit;

namespace Microsoft.DotNet.Build.Tasks.Workloads.Tests
{
public class CreateVisualStudioWorkloadSetTests : TestBase
{
[WindowsOnlyFact]
public static void ItCanCreateWorkloadSets()
public 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");
string testCaseDirectory = GetTestCaseDirectory();
string baseIntermediateOutputPath = testCaseDirectory;

if (Directory.Exists(baseIntermediateOutputPath))
{
Directory.Delete(baseIntermediateOutputPath, recursive: true);
}

ITaskItem[] workloadSetPackages = new[]
{
ITaskItem[] workloadSetPackages =
[
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();
var buildEngine = new MockBuildEngine();

CreateVisualStudioWorkloadSet createWorkloadSetTask = new CreateVisualStudioWorkloadSet()
{
BaseOutputPath = BaseOutputPath,
BaseOutputPath = Path.Combine(testCaseDirectory, "msi"),
BaseIntermediateOutputPath = baseIntermediateOutputPath,
BuildEngine = buildEngine,
WixToolsetPath = WixToolsetPath,
WorkloadSetPackageFiles = workloadSetPackages
WorkloadSetPackageFiles = workloadSetPackages,
WixExe = ToolsetInfo.WixExePath,
HeatExe = ToolsetInfo.HeatExePath,
WixExtensions = WixExtensions,
};

Assert.True(createWorkloadSetTask.Execute());
Assert.True(createWorkloadSetTask.Execute(), buildEngine.BuildErrorEvents.Count > 0 ?
buildEngine.BuildErrorEvents[0].Message : "Task failed. No error events");

// Validate the arm64 installer.
ITaskItem arm64Msi = createWorkloadSetTask.Msis.FirstOrDefault(i => i.GetMetadata(Metadata.Platform) == "arm64");
Assert.NotNull(arm64Msi);
ITaskItem x64Msi = createWorkloadSetTask.Msis.FirstOrDefault(i => i.GetMetadata(Metadata.Platform) == "x64");
Assert.NotNull(x64Msi);

var arm64MsiPath = arm64Msi.ItemSpec;
var x64MsiPath = x64Msi.ItemSpec;

// Spot check the x64 generated MSI.
ITaskItem msi = createWorkloadSetTask.Msis.Where(i => i.GetMetadata(Metadata.Platform) == "x64").FirstOrDefault();
Assert.NotNull(msi);
// Process the summary information stream's template to extract the MSIs target platform.
using SummaryInfo si = new(arm64MsiPath, enableWrite: false);
Assert.Equal("Arm64;1033", si.Template);

// 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");
// Upgrades are not supported, but we do generated stable GUIDs based on various
// properties including the target platform.
string upgradeCode = MsiUtils.GetProperty(arm64MsiPath, MsiProperty.UpgradeCode);
Assert.Equal("{A05B88DE-F40F-3C20-B6DA-719B8EED1D9F}", upgradeCode);
// Make sure the x64 and arm64 MSIs have different UpgradeCode properties.
string x64UpgradeCode = MsiUtils.GetProperty(x64MsiPath, MsiProperty.UpgradeCode);
Assert.NotEqual(upgradeCode, x64UpgradeCode);

// Workload sets are SxS. Verify that we don't have an Upgrade table.
Assert.False(MsiUtils.HasTable(msi.ItemSpec, "Upgrade"));
// Verify the installation record and dependency provider registry entries.
var registryKeys = MsiUtils.GetAllRegistryKeys(arm64MsiPath);
string productCode = MsiUtils.GetProperty(arm64MsiPath, MsiProperty.ProductCode);
string installationRecordKey = @"SOFTWARE\Microsoft\dotnet\InstalledWorkloadSets\arm64\9.0.100\9.0.100-baseline.1.23464.1";
string dependencyProviderKey = @"Software\Classes\Installer\Dependencies\Microsoft.NET.Workload.Set,9.0.100,9.0.100-baseline.1.23464.1,arm64";

// ProductCode and UpgradeCode values in the installation record should match the
// values from the Property table.
ValidateInstallationRecord(registryKeys, installationRecordKey,
"Microsoft.NET.Workload.Set,9.0.100,9.0.100-baseline.1.23464.1,arm64",
productCode, upgradeCode, "12.8.45");
ValidateDependencyProviderKey(registryKeys, dependencyProviderKey);

// Verify the workloadset version directory and only look at the long name version.
DirectoryRow versionDir = MsiUtils.GetAllDirectories(msi.ItemSpec).FirstOrDefault(d => string.Equals(d.Directory, "WorkloadSetVersionDir"));
DirectoryRow versionDir = MsiUtils.GetAllDirectories(arm64MsiPath).FirstOrDefault(d => string.Equals(d.Directory, "WorkloadSetVersionDir"));
Assert.NotNull(versionDir);
Assert.Contains("|9.0.0.100-baseline.1.23464.1", versionDir.DefaultDir);

// 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));
// Verify that the workloadset.json exists.
var files = MsiUtils.GetAllFiles(arm64MsiPath);
files.Should().Contain(f => f.FileName.EndsWith("|workloadset.json"));

// Verify the SWIX authoring for one of the workload set MSIs.
ITaskItem workloadSetSwixItem = createWorkloadSetTask.SwixProjects.FirstOrDefault(
s => s.GetMetadata(Metadata.PackageType) == DefaultValues.PackageTypeMsiWorkloadSet);
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();
ITaskItem workloadSetPackageGroupSwixItem = createWorkloadSetTask.SwixProjects.FirstOrDefault(
s => s.GetMetadata(Metadata.PackageType).Equals(DefaultValues.PackageTypeWorkloadSetPackageGroup));
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);
Expand Down
Loading
Loading