From 5a4130e059b88c6f33f7c1304c8442baa32da69e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sat, 20 Mar 2021 08:37:55 -0700 Subject: [PATCH 1/2] Follow ups for Blazor AOT * Add Emscripten packs to manifest * Update acquire tool to use manifest from the dotnet sdk * Add AOT option to templates --- eng/Version.Details.xml | 12 +++ eng/Versions.props | 9 +- .../BlazorManifest/acquire/Program.cs | 101 +++++++----------- .../BlazorManifest/src/BlazorManifest.csproj | 3 + .../src/WorkloadManifest.json.in | 35 +++++- 5 files changed, 91 insertions(+), 69 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 396d27e27030..8079a4b722c0 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -284,6 +284,18 @@ https://github.com/dotnet/runtime 0f64b267ac0552f07b06f18103581b880c8c53c6 + + + https://github.com/dotnet/runtime + 0f64b267ac0552f07b06f18103581b880c8c53c6 + + + https://github.com/dotnet/runtime + 0f64b267ac0552f07b06f18103581b880c8c53c6 + + + https://github.com/dotnet/runtime + 0f64b267ac0552f07b06f18103581b880c8c53c6 https://github.com/dotnet/runtime diff --git a/eng/Versions.props b/eng/Versions.props index 24b39998041e..61be14d1c3b4 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -68,9 +68,12 @@ 6.0.0-preview.3.21167.1 6.0.0-preview.3.21167.1 6.0.0-preview.3.21167.1 - 6.0.0-preview.3.21167.1 - 6.0.0-preview.3.21167.1 - 6.0.0-preview.3.21167.1 + 6.0.0-preview.3.21169.6 + 6.0.0-preview.3.21169.6 + 6.0.0-preview.3.21169.6 + 6.0.0-preview.3.21169.6 + 6.0.0-preview.3.21169.6 + 6.0.0-preview.3.21169.6 6.0.0-preview.3.21167.1 6.0.0-preview.3.21167.1 6.0.0-preview.3.21167.1 diff --git a/src/Components/WebAssembly/BlazorManifest/acquire/Program.cs b/src/Components/WebAssembly/BlazorManifest/acquire/Program.cs index 6f8a0526a2d8..ef4b476914d0 100644 --- a/src/Components/WebAssembly/BlazorManifest/acquire/Program.cs +++ b/src/Components/WebAssembly/BlazorManifest/acquire/Program.cs @@ -25,23 +25,19 @@ static string GetDotnetPath() static int Main(string[] args) { - System.Console.WriteLine(MuxerPath); var sdkDirectory = args.Length > 0 ? args[0] : Path.GetDirectoryName(MuxerPath); var tempDirectory = Path.Combine(Directory.GetCurrentDirectory(), "tmp", Path.GetRandomFileName()); var restoreDirectory = Path.Combine(tempDirectory, ".nuget"); try { - var restore = Restore(tempDirectory, restoreDirectory, out var packs); + var packs = GetPacks(sdkDirectory); + var restore = RestorePacks(tempDirectory, restoreDirectory, packs); if (restore != 0) { return restore; } - var sourceManifestDirectory = Path.Combine(restoreDirectory, "microsoft.net.sdk.blazorwebassembly.aot", ManifestVersion); - var targetManifestDirectory = Path.Combine(sdkDirectory, "sdk-manifests", ManifestVersion, "Microsoft.NET.Sdk.BlazorWebAssembly.AOT"); - Move(sourceManifestDirectory, targetManifestDirectory); - foreach (var (id, version) in packs) { var source = Path.Combine(restoreDirectory, id.ToLowerInvariant(), version); @@ -59,7 +55,7 @@ static int Main(string[] args) sdkVersionProc.WaitForExit(); var sdkVersion = sdkVersionProc.StandardOutput.ReadToEnd().Trim(); var sentinelPath = Path.Combine(sdkDirectory, "sdk", sdkVersion, "EnableWorkloadResolver.sentinel"); - Console.WriteLine($"Writing sentinel to {sentinelPath}."); + Console.WriteLine($"Enabling Workloads support in dotnet SDK v{sdkVersion}."); File.WriteAllBytes(sentinelPath, Array.Empty()); } @@ -84,64 +80,17 @@ static void Move(string source, string destination) Directory.Move(source, destination); } - static int Restore(string tempDirectory, string restoreDirectory, out List<(string, string)> packs) + static List<(string Id, string Version)> GetPacks(string sdkDirectory) { - packs = null; - - var restoreProject = Path.Combine(tempDirectory, "restore", "Restore.csproj"); - var restoreProjectDirectory = Directory.CreateDirectory(Path.GetDirectoryName(restoreProject)); - - File.WriteAllText(Path.Combine(restoreProjectDirectory.FullName, "Directory.Build.props"), ""); - File.WriteAllText(Path.Combine(restoreProjectDirectory.FullName, "Directory.Build.targets"), ""); - - var projectFile = @" - - - net6.0 - - - - - -"; - File.WriteAllText(restoreProject, projectFile); - - Console.WriteLine("Restoring..."); - - var process = Process.Start(new ProcessStartInfo - { - FileName = MuxerPath, - ArgumentList = { "restore", restoreProject }, - Environment = - { - ["NUGET_PACKAGES"] = restoreDirectory, - }, - }); - process.WaitForExit(); - if (process.ExitCode != 0) + var manifestDirectory = Path.Combine(sdkDirectory, "sdk-manifests", ManifestVersion, "Microsoft.NET.Workload.BlazorWebAssembly"); + if (!Directory.Exists(manifestDirectory)) { - Console.Error.WriteLine("Unable to restore Microsoft.NET.Sdk.BlazorWebAssembly.AOT workload."); - return 1; + throw new DirectoryNotFoundException($"Cound not find directory {manifestDirectory}. A 6.0-preview3 SDK or newer is required for this tool to function."); } - var manifestDirectory = Path.Combine(restoreDirectory, "microsoft.net.sdk.blazorwebassembly.aot"); - var version = Directory.EnumerateDirectories(manifestDirectory).First(); - - manifestDirectory = Path.Combine(manifestDirectory, ManifestVersion); - Directory.Move(version, manifestDirectory); - var manifestPath = Path.Combine(manifestDirectory, "WorkloadManifest.json"); var manifest = JsonSerializer.Deserialize(File.ReadAllBytes(manifestPath), new JsonSerializerOptions(JsonSerializerDefaults.Web)); - - projectFile = @" - - - net6.0 - $(NoWarn);NU1213 - - -"; - packs = new List<(string id, string version)>(); + var packs = new List<(string, string)>(); foreach (var item in manifest.Packs) { var packageName = item.Key; @@ -161,34 +110,56 @@ static int Restore(string tempDirectory, string restoreDirectory, out List<(stri } else { - Console.Error.WriteLine("Unsupported platform."); - return 1; + throw new NotSupportedException("Unsupported OS platform."); } } - projectFile += @$""; packs.Add((packageName, item.Value.Version)); } + return packs; + } + + static int RestorePacks(string tempDirectory, string restoreDirectory, List<(string Id, string Version)> packs) + { + var restoreProject = Path.Combine(tempDirectory, "restore", "Restore.csproj"); + var restoreProjectDirectory = Directory.CreateDirectory(Path.GetDirectoryName(restoreProject)); + + File.WriteAllText(Path.Combine(restoreProjectDirectory.FullName, "Directory.Build.props"), ""); + File.WriteAllText(Path.Combine(restoreProjectDirectory.FullName, "Directory.Build.targets"), ""); + + var projectFile = @" + + + net6.0 + $(NoWarn);NU1213 + + +"; + foreach (var (Id, Version) in packs) + { + projectFile += $""; + } + projectFile += @" "; File.WriteAllText(restoreProject, projectFile); - process = Process.Start(new ProcessStartInfo + var process = Process.Start(new ProcessStartInfo { FileName = MuxerPath, ArgumentList = { "restore", restoreProject }, +#if !DEBUG RedirectStandardError = true, RedirectStandardOutput = true, +#endif Environment = { ["NUGET_PACKAGES"] = restoreDirectory, }, }); process.WaitForExit(); - - return 0; } diff --git a/src/Components/WebAssembly/BlazorManifest/src/BlazorManifest.csproj b/src/Components/WebAssembly/BlazorManifest/src/BlazorManifest.csproj index 5fad080b429d..501661500dd9 100644 --- a/src/Components/WebAssembly/BlazorManifest/src/BlazorManifest.csproj +++ b/src/Components/WebAssembly/BlazorManifest/src/BlazorManifest.csproj @@ -17,6 +17,9 @@ MicrosoftNETRuntimeMonoAOTCompilerTaskVersion=$(MicrosoftNETRuntimeMonoAOTCompilerTaskVersion); MicrosoftNETRuntimeWebAssemblySdkVersion=$(MicrosoftNETRuntimeWebAssemblySdkVersion); MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion=$(MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion); + MicrosoftNETRuntimeEmscripten2012NodeVersion=$(MicrosoftNETRuntimeEmscripten2012Nodewinx64Version); + MicrosoftNETRuntimeEmscripten2012PythonVersion=$(MicrosoftNETRuntimeEmscripten2012Pythonwinx64Version); + MicrosoftNETRuntimeEmscripten2012SdkVersion=$(MicrosoftNETRuntimeEmscripten2012Sdkwinx64Version); $(IntermediateOutputPath)WorkloadManifest.json diff --git a/src/Components/WebAssembly/BlazorManifest/src/WorkloadManifest.json.in b/src/Components/WebAssembly/BlazorManifest/src/WorkloadManifest.json.in index e35868204057..6530b28dcc0e 100644 --- a/src/Components/WebAssembly/BlazorManifest/src/WorkloadManifest.json.in +++ b/src/Components/WebAssembly/BlazorManifest/src/WorkloadManifest.json.in @@ -6,7 +6,10 @@ "packs": [ "Microsoft.NET.Runtime.MonoAOTCompiler.Task", "Microsoft.NET.Runtime.WebAssembly.Sdk", - "Microsoft.Netcore.App.Runtime.Aot.Cross.browser-wasm" + "Microsoft.Netcore.App.Runtime.Aot.Cross.browser-wasm", + "Microsoft.NET.Runtime.Emscripten.2.0.12.Node", + "Microsoft.NET.Runtime.Emscripten.2.0.12.Python", + "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk" ] } }, @@ -28,6 +31,36 @@ "linux-x64": "microsoft.netcore.app.runtime.aot.linux-x64.cross.browser-wasm", "osx-x64": "microsoft.netcore.app.runtime.aot.osx-x64.cross.browser-wasm" } + }, + "Microsoft.NET.Runtime.Emscripten.2.0.12.Node" : { + "kind": "Sdk", + "version": "${MicrosoftNETRuntimeEmscripten2012NodeVersion}", + "alias-to": { + "win-x86": "Microsoft.NET.Runtime.Emscripten.2.0.12.Node.win-x86", + "win-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Node.win-x64", + "linux-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Node.linux-x64", + "osx-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Node.osx-x64" + } + }, + "Microsoft.NET.Runtime.Emscripten.2.0.12.Python" : { + "kind": "Sdk", + "version": "${MicrosoftNETRuntimeEmscripten2012PythonVersion}", + "alias-to": { + "win-x86": "Microsoft.NET.Runtime.Emscripten.2.0.12.Python.win-x86", + "win-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Python.win-x64", + "linux-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Python.linux-x64", + "osx-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Python.osx-x64" + } + }, + "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk" : { + "kind": "Sdk", + "version": "${MicrosoftNETRuntimeEmscripten2012SdkVersion}", + "alias-to": { + "win-x86": "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk.win-x86", + "win-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk.win-x64", + "linux-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk.linux-x64", + "osx-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk.osx-x64" + } } } } From 1f6a1b191f0afd17294289fbdc3dc3a66b8abcf8 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sat, 20 Mar 2021 14:20:41 -0700 Subject: [PATCH 2/2] Undo Emscripten for now --- eng/Version.Details.xml | 12 ------- eng/Versions.props | 9 ++--- .../BlazorManifest/src/BlazorManifest.csproj | 3 -- .../src/WorkloadManifest.json.in | 35 +------------------ 4 files changed, 4 insertions(+), 55 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 8079a4b722c0..396d27e27030 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -284,18 +284,6 @@ https://github.com/dotnet/runtime 0f64b267ac0552f07b06f18103581b880c8c53c6 - - - https://github.com/dotnet/runtime - 0f64b267ac0552f07b06f18103581b880c8c53c6 - - - https://github.com/dotnet/runtime - 0f64b267ac0552f07b06f18103581b880c8c53c6 - - - https://github.com/dotnet/runtime - 0f64b267ac0552f07b06f18103581b880c8c53c6 https://github.com/dotnet/runtime diff --git a/eng/Versions.props b/eng/Versions.props index 61be14d1c3b4..24b39998041e 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -68,12 +68,9 @@ 6.0.0-preview.3.21167.1 6.0.0-preview.3.21167.1 6.0.0-preview.3.21167.1 - 6.0.0-preview.3.21169.6 - 6.0.0-preview.3.21169.6 - 6.0.0-preview.3.21169.6 - 6.0.0-preview.3.21169.6 - 6.0.0-preview.3.21169.6 - 6.0.0-preview.3.21169.6 + 6.0.0-preview.3.21167.1 + 6.0.0-preview.3.21167.1 + 6.0.0-preview.3.21167.1 6.0.0-preview.3.21167.1 6.0.0-preview.3.21167.1 6.0.0-preview.3.21167.1 diff --git a/src/Components/WebAssembly/BlazorManifest/src/BlazorManifest.csproj b/src/Components/WebAssembly/BlazorManifest/src/BlazorManifest.csproj index 501661500dd9..5fad080b429d 100644 --- a/src/Components/WebAssembly/BlazorManifest/src/BlazorManifest.csproj +++ b/src/Components/WebAssembly/BlazorManifest/src/BlazorManifest.csproj @@ -17,9 +17,6 @@ MicrosoftNETRuntimeMonoAOTCompilerTaskVersion=$(MicrosoftNETRuntimeMonoAOTCompilerTaskVersion); MicrosoftNETRuntimeWebAssemblySdkVersion=$(MicrosoftNETRuntimeWebAssemblySdkVersion); MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion=$(MicrosoftNETCoreAppRuntimeAOTwinx64CrossbrowserwasmVersion); - MicrosoftNETRuntimeEmscripten2012NodeVersion=$(MicrosoftNETRuntimeEmscripten2012Nodewinx64Version); - MicrosoftNETRuntimeEmscripten2012PythonVersion=$(MicrosoftNETRuntimeEmscripten2012Pythonwinx64Version); - MicrosoftNETRuntimeEmscripten2012SdkVersion=$(MicrosoftNETRuntimeEmscripten2012Sdkwinx64Version); $(IntermediateOutputPath)WorkloadManifest.json diff --git a/src/Components/WebAssembly/BlazorManifest/src/WorkloadManifest.json.in b/src/Components/WebAssembly/BlazorManifest/src/WorkloadManifest.json.in index 6530b28dcc0e..e35868204057 100644 --- a/src/Components/WebAssembly/BlazorManifest/src/WorkloadManifest.json.in +++ b/src/Components/WebAssembly/BlazorManifest/src/WorkloadManifest.json.in @@ -6,10 +6,7 @@ "packs": [ "Microsoft.NET.Runtime.MonoAOTCompiler.Task", "Microsoft.NET.Runtime.WebAssembly.Sdk", - "Microsoft.Netcore.App.Runtime.Aot.Cross.browser-wasm", - "Microsoft.NET.Runtime.Emscripten.2.0.12.Node", - "Microsoft.NET.Runtime.Emscripten.2.0.12.Python", - "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk" + "Microsoft.Netcore.App.Runtime.Aot.Cross.browser-wasm" ] } }, @@ -31,36 +28,6 @@ "linux-x64": "microsoft.netcore.app.runtime.aot.linux-x64.cross.browser-wasm", "osx-x64": "microsoft.netcore.app.runtime.aot.osx-x64.cross.browser-wasm" } - }, - "Microsoft.NET.Runtime.Emscripten.2.0.12.Node" : { - "kind": "Sdk", - "version": "${MicrosoftNETRuntimeEmscripten2012NodeVersion}", - "alias-to": { - "win-x86": "Microsoft.NET.Runtime.Emscripten.2.0.12.Node.win-x86", - "win-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Node.win-x64", - "linux-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Node.linux-x64", - "osx-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Node.osx-x64" - } - }, - "Microsoft.NET.Runtime.Emscripten.2.0.12.Python" : { - "kind": "Sdk", - "version": "${MicrosoftNETRuntimeEmscripten2012PythonVersion}", - "alias-to": { - "win-x86": "Microsoft.NET.Runtime.Emscripten.2.0.12.Python.win-x86", - "win-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Python.win-x64", - "linux-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Python.linux-x64", - "osx-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Python.osx-x64" - } - }, - "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk" : { - "kind": "Sdk", - "version": "${MicrosoftNETRuntimeEmscripten2012SdkVersion}", - "alias-to": { - "win-x86": "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk.win-x86", - "win-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk.win-x64", - "linux-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk.linux-x64", - "osx-x64": "Microsoft.NET.Runtime.Emscripten.2.0.12.Sdk.osx-x64" - } } } }