未验证 提交 81e313a9 编写于 作者: A Ankit Jain 提交者: GitHub

[wasm] Add new `wasm-experimental` workload (#71974)

* InstallWorkloadFromArtifact: Support multiple workloads

* [wasm] Move the templates pack to a new workload - wasm-experimental
上级 ec86274b
......@@ -137,6 +137,10 @@
ManifestName="Microsoft.NET.Workload.Mono.ToolChain"
Version="$(PackageVersion)"
VersionBand="$(SdkBandVersion)" />
<WorkloadIdForTesting Include="wasm-experimental"
ManifestName="Microsoft.NET.Workload.Mono.ToolChain"
Version="$(PackageVersion)"
VersionBand="$(SdkBandVersion)" />
<WasmExtraFilesToDeploy Condition="'$(_UseWasmSymbolicator)' == 'true'" Include="$(MonoProjectRoot)wasm\data\wasm-symbol-patterns.txt" />
<WasmExtraFilesToDeploy Condition="'$(_UseWasmSymbolicator)' == 'true'" Include="$(ArtifactsBinDir)WasmSymbolicator\$(Configuration)\$(NetCoreAppToolCurrent)\WasmSymbolicator.dll" />
......
......@@ -135,7 +135,7 @@
<Message Text="Packages found in $(LibrariesShippingPackagesDir): @(_BuiltNuGets)" Importance="Low" />
<InstallWorkloadFromArtifacts
WorkloadId="@(WorkloadIdForTesting)"
WorkloadIds="@(WorkloadIdForTesting)"
VersionBand="$(SdkBandVersion)"
LocalNuGetsPath="$(LibrariesShippingPackagesDir)"
TemplateNuGetConfigPath="$(RepoRoot)NuGet.config"
......@@ -148,7 +148,7 @@
Outputs="$(SdkWithNoWorkload_WorkloadStampPath)">
<InstallWorkloadFromArtifacts
WorkloadId="@(WorkloadIdForTesting)"
WorkloadIds="@(WorkloadIdForTesting)"
VersionBand="$(SdkBandVersion)"
LocalNuGetsPath="$(LibrariesShippingPackagesDir)"
TemplateNuGetConfigPath="$(RepoRoot)NuGet.config"
......
......@@ -8,13 +8,20 @@
"description": ".NET WebAssembly build tools",
"packs": [
"Microsoft.NET.Runtime.WebAssembly.Sdk",
"Microsoft.NET.Runtime.WebAssembly.Templates",
"Microsoft.NETCore.App.Runtime.Mono.browser-wasm",
"Microsoft.NETCore.App.Runtime.AOT.Cross.browser-wasm"
],
"extends": [ "microsoft-net-runtime-mono-tooling", "microsoft-net-sdk-emscripten" ],
"platforms": [ "win-x64", "linux-x64", "osx-x64", "osx-arm64" ]
},
"wasm-experimental": {
"description": ".NET WebAssembly experimental",
"packs": [
"Microsoft.NET.Runtime.WebAssembly.Templates"
],
"extends": [ "wasm-tools" ],
"platforms": [ "win-x64", "linux-x64", "osx-x64", "osx-arm64" ]
},
"microsoft-net-runtime-android": {
"abstract": true,
"description": "Android Mono Runtime",
......
......@@ -4,9 +4,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Build.Framework;
......@@ -19,7 +19,7 @@ namespace Microsoft.Workload.Build.Tasks
public class InstallWorkloadFromArtifacts : Task
{
[Required, NotNull]
public ITaskItem? WorkloadId { get; set; }
public ITaskItem[] WorkloadIds { get; set; } = Array.Empty<ITaskItem>();
[Required, NotNull]
public string? VersionBand { get; set; }
......@@ -41,7 +41,12 @@ public override bool Execute()
{
try
{
return ExecuteInternal();
foreach (var workloadIdItem in WorkloadIds)
{
if (!ExecuteInternal(workloadIdItem))
return false;
}
return true;
}
catch (LogAsErrorException laee)
{
......@@ -50,10 +55,10 @@ public override bool Execute()
}
}
private bool ExecuteInternal()
private bool ExecuteInternal(ITaskItem workloadId)
{
if (!HasMetadata(WorkloadId, nameof(WorkloadId), "Version") ||
!HasMetadata(WorkloadId, nameof(WorkloadId), "ManifestName"))
if (!HasMetadata(workloadId, nameof(workloadId), "Version") ||
!HasMetadata(workloadId, nameof(workloadId), "ManifestName"))
{
return false;
}
......@@ -70,10 +75,10 @@ private bool ExecuteInternal()
return false;
}
Log.LogMessage(MessageImportance.High, $"{Environment.NewLine}** Installing workload manifest {WorkloadId.ItemSpec} **{Environment.NewLine}");
Log.LogMessage(MessageImportance.High, $"{Environment.NewLine}** Installing workload manifest {workloadId.ItemSpec} **{Environment.NewLine}");
string nugetConfigContents = GetNuGetConfig();
if (!InstallWorkloadManifest(WorkloadId.GetMetadata("ManifestName"), WorkloadId.GetMetadata("Version"), nugetConfigContents, stopOnMissing: true))
if (!InstallWorkloadManifest(workloadId, workloadId.GetMetadata("ManifestName"), workloadId.GetMetadata("Version"), nugetConfigContents, stopOnMissing: true))
return false;
if (OnlyUpdateManifests)
......@@ -86,7 +91,7 @@ private bool ExecuteInternal()
(int exitCode, string output) = Utils.TryRunProcess(
Log,
Path.Combine(SdkDir, "dotnet"),
$"workload install --skip-manifest-update --no-cache --configfile \"{nugetConfigPath}\" {WorkloadId.ItemSpec}",
$"workload install --skip-manifest-update --no-cache --configfile \"{nugetConfigPath}\" {workloadId.ItemSpec}",
workingDir: Path.GetTempPath(),
silent: false,
debugMessageImportance: MessageImportance.High);
......@@ -115,7 +120,7 @@ private string GetNuGetConfig()
return contents.Replace(s_nugetInsertionTag, $@"<add key=""nuget-local"" value=""{LocalNuGetsPath}"" />");
}
private bool InstallWorkloadManifest(string name, string version, string nugetConfigContents, bool stopOnMissing)
private bool InstallWorkloadManifest(ITaskItem workloadId, string name, string version, string nugetConfigContents, bool stopOnMissing)
{
Log.LogMessage(MessageImportance.High, $"Installing workload manifest for {name}/{version}");
......@@ -168,9 +173,9 @@ private bool InstallWorkloadManifest(string name, string version, string nugetCo
{
foreach ((string depName, string depVersion) in manifest.DependsOn)
{
if (!InstallWorkloadManifest(depName, depVersion, nugetConfigContents, stopOnMissing: false))
if (!InstallWorkloadManifest(workloadId, depName, depVersion, nugetConfigContents, stopOnMissing: false))
{
Log.LogWarning($"Could not install manifest {depName}/{depVersion}. This can be ignored if the workload {WorkloadId.ItemSpec} doesn't depend on it.");
Log.LogWarning($"Could not install manifest {depName}/{depVersion}. This can be ignored if the workload {workloadId.ItemSpec} doesn't depend on it.");
continue;
}
}
......@@ -201,7 +206,7 @@ private string FindSubDirIgnoringCase(string parentDir, string dirName)
+ $"{Environment.NewLine}Using the first one: {first}");
}
return first ?? Path.Combine(parentDir, dirName);
return first ?? Path.Combine(parentDir, dirName.ToLower(CultureInfo.InvariantCulture));
}
private sealed record ManifestInformation(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册