-
Notifications
You must be signed in to change notification settings - Fork 378
Add support for .NET workload sets #14083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eef34f2
Add support for .NET workload sets
joeloff b0ff45f
Cleanup formatting
joeloff 05ddffa
Format cleanup
joeloff 009007b
PR Feedback
joeloff f683ede
PR feedback
joeloff a75875f
Merge branch 'main' into workload-sets
joeloff f004ef8
Fix iOS package version
joeloff 7433afa
Merge branch 'main' into workload-sets
joeloff f79ad7d
PR feedback
joeloff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/CreateVisualStudioWorkloadSetTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.