Skip to content

Commit

Permalink
Add ability to generate workload components/pack authoring with out-o… (
Browse files Browse the repository at this point in the history
#13642)

* Add ability to generate workload components/pack authoring with out-of-support flag

* Tweak tests

* PR feedback: Move comment to correct section
  • Loading branch information
joeloff authored May 24, 2023
1 parent eeb78d0 commit 8905e6d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public static void ItCanCreateWorkloads()
ShortNames = shortNames,
WixToolsetPath = TestBase.WixToolsetPath,
WorkloadManifestPackageFiles = manifestsPackages,
IsOutOfSupportInVisualStudio = true
};

bool result = createWorkloadTask.Execute();
Expand Down Expand Up @@ -93,6 +94,7 @@ public static void ItCanCreateWorkloads()

// Emscripten is an abstract workload so it should be a component group.
Assert.Contains("vs.package.type=component", componentSwr);
Assert.Contains("vs.package.outOfSupport=yes", componentSwr);
Assert.Contains("isUiGroup=yes", componentSwr);
Assert.Contains("version=5.6.7.8", componentSwr);

Expand All @@ -109,6 +111,7 @@ public static void ItCanCreateWorkloads()
Assert.Contains("vs.package.type=msi", manifestMsiSwr);
Assert.Contains("vs.package.chip=x64", manifestMsiSwr);
Assert.DoesNotContain("vs.package.machineArch", manifestMsiSwr);
Assert.DoesNotContain("vs.package.outOfSupport", manifestMsiSwr);

// Verify that no arm64 MSI authoring for VS. EMSDK doesn't define RIDs for arm64, but manifests always generate
// arm64 MSIs for the CLI based installs so we should not see that.
Expand All @@ -122,6 +125,7 @@ public static void ItCanCreateWorkloads()
string packMsiSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(pythonPackSwixItem.ItemSpec), "msi.swr"));
Assert.Contains("package name=Microsoft.Emscripten.Python.6.0.4", packMsiSwr);
Assert.Contains("vs.package.chip=x64", packMsiSwr);
Assert.Contains("vs.package.outOfSupport=yes", packMsiSwr);
Assert.DoesNotContain("vs.package.machineArch", packMsiSwr);
}

Expand Down Expand Up @@ -204,6 +208,8 @@ public static void ItCanCreateWorkloadsThatSupportArm64InVisualStudio()
Assert.Contains("vs.package.type=component", componentSwr);
Assert.Contains("isUiGroup=yes", componentSwr);
Assert.Contains("version=5.6.7.8", componentSwr);
// Default setting should be off
Assert.Contains("vs.package.outOfSupport=no", componentSwr);

// Verify pack dependencies. These should map to MSI packages. The VS package IDs should be the non-aliased
// pack IDs and version from the workload manifest. The actual VS packages will point to the MSIs generated from the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ public ITaskItem[] IceSuppressions
set;
}

/// <summary>
/// Determines whether the component (and related packs) should be flagged as
/// out-of-support in Visual Studio.
/// </summary>
public bool IsOutOfSupportInVisualStudio
{
get;
set;
}

/// <summary>
/// The version to assign to workload manifest installers.
/// </summary>
Expand Down Expand Up @@ -263,7 +273,6 @@ public override bool Execute()
packGroupJsonList.Add(packGroupJson);
}


foreach (WorkloadPackId packId in wd.Packs)
{
WorkloadPack pack = manifest.Packs[packId];
Expand Down Expand Up @@ -393,8 +402,8 @@ public override bool Execute()
if (_supportsMachineArch[sdkFeatureBand] || !string.Equals(msiOutputItem.GetMetadata(Metadata.Platform), DefaultValues.arm64))
{
MsiSwixProject swixProject = _supportsMachineArch[sdkFeatureBand] ?
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, sdkFeatureBand, chip: null, machineArch: msiOutputItem.GetMetadata(Metadata.Platform)) :
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, sdkFeatureBand, chip: msiOutputItem.GetMetadata(Metadata.Platform));
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, sdkFeatureBand, chip: null, machineArch: msiOutputItem.GetMetadata(Metadata.Platform), outOfSupport: IsOutOfSupportInVisualStudio) :
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, sdkFeatureBand, chip: msiOutputItem.GetMetadata(Metadata.Platform), outOfSupport: IsOutOfSupportInVisualStudio);
string swixProj = swixProject.Create();

ITaskItem swixProjectItem = new TaskItem(swixProj);
Expand Down Expand Up @@ -441,8 +450,8 @@ public override bool Execute()
if (_supportsMachineArch[manifestPackage.SdkFeatureBand] || !string.Equals(msiOutputItem.GetMetadata(Metadata.Platform), DefaultValues.arm64))
{
MsiSwixProject swixProject = _supportsMachineArch[manifestPackage.SdkFeatureBand] ?
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, manifestPackage.SdkFeatureBand, chip: null, machineArch: msiOutputItem.GetMetadata(Metadata.Platform)) :
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, manifestPackage.SdkFeatureBand, chip: msiOutputItem.GetMetadata(Metadata.Platform));
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, manifestPackage.SdkFeatureBand, chip: null, machineArch: msiOutputItem.GetMetadata(Metadata.Platform), outOfSupport: IsOutOfSupportInVisualStudio) :
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, manifestPackage.SdkFeatureBand, chip: msiOutputItem.GetMetadata(Metadata.Platform), outOfSupport: IsOutOfSupportInVisualStudio);
string swixProj = swixProject.Create();

ITaskItem swixProjectItem = new TaskItem(swixProj);
Expand All @@ -468,7 +477,8 @@ public override bool Execute()
// Don't generate a SWIX package if the MSI targets arm64 and VS doesn't support machineArch
if (_supportsMachineArch[msi.Package.SdkFeatureBand] || !string.Equals(msiOutputItem.GetMetadata(Metadata.Platform), DefaultValues.arm64))
{
// Generate SWIX authoring for the MSI package.
// Generate SWIX authoring for the MSI package. Do not flag manifest MSI packages for out-of-support.
// These are typically pulled in through .NET SDK components.
MsiSwixProject swixProject = _supportsMachineArch[msi.Package.SdkFeatureBand] ?
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, msi.Package.SdkFeatureBand, chip: null, machineArch: msiOutputItem.GetMetadata(Metadata.Platform)) :
new(msiOutputItem, BaseIntermediateOutputPath, BaseOutputPath, msi.Package.SdkFeatureBand, chip: msiOutputItem.GetMetadata(Metadata.Platform));
Expand Down Expand Up @@ -497,7 +507,7 @@ public override bool Execute()
// artifacts.
_ = Parallel.ForEach(swixComponents, swixComponent =>
{
ComponentSwixProject swixComponentProject = new(swixComponent, BaseIntermediateOutputPath, BaseOutputPath);
ComponentSwixProject swixComponentProject = new(swixComponent, BaseIntermediateOutputPath, BaseOutputPath, IsOutOfSupportInVisualStudio);
ITaskItem swixProjectItem = new TaskItem(swixComponentProject.Create());
swixProjectItem.SetMetadata(Metadata.SdkFeatureBand, $"{swixComponent.SdkFeatureBand}");
swixProjectItem.SetMetadata(Metadata.PackageType, DefaultValues.PackageTypeComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ protected override string ProjectSourceDirectory
get;
}

public ComponentSwixProject(SwixComponent component, string baseIntermediateOutputPath, string baseOutputPath) :
base(component.Name, component.Version, baseIntermediateOutputPath, baseOutputPath)
public ComponentSwixProject(SwixComponent component, string baseIntermediateOutputPath, string baseOutputPath, bool outOfSupport = false) :
base(component.Name, component.Version, baseIntermediateOutputPath, baseOutputPath, outOfSupport)
{
_component = component;
ValidateRelativePackagePath(GetRelativePackagePath());
Expand All @@ -43,6 +43,7 @@ public ComponentSwixProject(SwixComponent component, string baseIntermediateOutp
ReplacementTokens[SwixTokens.__VS_COMPONENT_DESCRIPTION__] = component.Description;
ReplacementTokens[SwixTokens.__VS_COMPONENT_CATEGORY__] = component.Category;
ReplacementTokens[SwixTokens.__VS_IS_UI_GROUP__] = component.IsUiGroup ? "yes" : "no";
ReplacementTokens[SwixTokens.__VS_PACKAGE_OUT_OF_SUPPORT__] = OutOfSupport ? "yes" : "no";
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected override string ProjectSourceDirectory

public MsiSwixProject(ITaskItem msi, string baseIntermediateOutputPath, string baseOutputPath,
ReleaseVersion sdkFeatureBand,
string chip = null, string machineArch = null, string productArch = null) : base(msi.GetMetadata(Metadata.SwixPackageId), new Version(msi.GetMetadata(Metadata.Version)), baseIntermediateOutputPath, baseOutputPath)
string chip = null, string machineArch = null, string productArch = null, bool outOfSupport = false) : base(msi.GetMetadata(Metadata.SwixPackageId), new Version(msi.GetMetadata(Metadata.Version)), baseIntermediateOutputPath, baseOutputPath, outOfSupport)
{
_msi = msi;
Chip = chip;
Expand Down Expand Up @@ -135,6 +135,11 @@ public override string Create()
msiWriter.WriteLine($" vs.package.machineArch={MachineArch}");
}

if (OutOfSupport)
{
msiWriter.WriteLine($" vs.package.outOfSupport=yes");
}

msiWriter.WriteLine($" vs.package.type=msi");
msiWriter.WriteLine();
msiWriter.WriteLine($"vs.installSize");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public string Id
set;
}

/// <summary>
/// Determines whether the package is marked as out-of-support.
/// </summary>
public bool OutOfSupport
{
get;
set;
}

/// <summary>
/// The version of the SWIX package.
/// </summary>
Expand All @@ -47,11 +56,12 @@ public Version Version
/// </summary>
/// <param name="id">The SWIX package ID.</param>
/// <param name="version">The package version.</param>
public SwixProjectBase(string id, Version version, string baseIntermediateOutputPath, string baseOutputPath) :
public SwixProjectBase(string id, Version version, string baseIntermediateOutputPath, string baseOutputPath, bool outOfSupport = false) :
base(baseIntermediateOutputPath, baseOutputPath)
{
Id = id;
Version = version;
OutOfSupport = outOfSupport;

ReplacementTokens[SwixTokens.__VS_PACKAGE_NAME__] = Id;
ReplacementTokens[SwixTokens.__VS_PACKAGE_VERSION__] = $"{Version}";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.DotNet.Build.Tasks.Workloads.Swix
Expand All @@ -15,6 +15,7 @@ public static class SwixTokens
public static readonly string __VS_PACKAGE_CHIP__ = nameof(__VS_PACKAGE_CHIP__);
public static readonly string __VS_PACKAGE_INSTALL_SIZE_SYSTEM_DRIVE__ = nameof(__VS_PACKAGE_INSTALL_SIZE_SYSTEM_DRIVE__);
public static readonly string __VS_PACKAGE_NAME__ = nameof(__VS_PACKAGE_NAME__);
public static readonly string __VS_PACKAGE_OUT_OF_SUPPORT__ = nameof(__VS_PACKAGE_OUT_OF_SUPPORT__);
public static readonly string __VS_PACKAGE_PRODUCT_ARCH__ = nameof(__VS_PACKAGE_PRODUCT_ARCH__);
public static readonly string __VS_PAYLOAD_SIZE__ = nameof(__VS_PAYLOAD_SIZE__);
public static readonly string __VS_PAYLOAD_SOURCE__ = nameof(__VS_PAYLOAD_SOURCE__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use vs
package name=__VS_PACKAGE_NAME__
version=__VS_PACKAGE_VERSION__
vs.package.type=component
vs.package.outOfSupport=__VS_PACKAGE_OUT_OF_SUPPORT__

vs.properties
isUiGroup=__VS_IS_UI_GROUP__
Expand Down

0 comments on commit 8905e6d

Please sign in to comment.