Skip to content
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

[wasm] Add new wasm-experimental workload #71974

Merged
merged 3 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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 eng/testing/tests.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
4 changes: 2 additions & 2 deletions eng/testing/workloads-testing.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -148,7 +148,7 @@
Outputs="$(SdkWithNoWorkload_WorkloadStampPath)">

<InstallWorkloadFromArtifacts
WorkloadId="@(WorkloadIdForTesting)"
WorkloadIds="@(WorkloadIdForTesting)"
VersionBand="$(SdkBandVersion)"
LocalNuGetsPath="$(LibrariesShippingPackagesDir)"
TemplateNuGetConfigPath="$(RepoRoot)NuGet.config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 18 additions & 13 deletions src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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; }
Expand All @@ -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)
{
Expand All @@ -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;
}
Expand All @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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}");

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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(
Expand Down