From d3ad227b60221755ebbe01078c71145973a4579e Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 27 Aug 2021 12:21:14 -0400 Subject: [PATCH 01/46] rebased --- .../scenarios/BuildWasmAppsJobsList.txt | 32 +-- eng/testing/tests.mobile.targets | 3 +- eng/testing/tests.wasm.targets | 22 +- src/libraries/sendtohelixhelp.proj | 4 +- src/mono/sample/mbr/browser/WasmDelta.csproj | 1 - src/mono/sample/wasm/Directory.Build.targets | 5 - src/mono/sample/wasm/console/Program.cs | 2 +- src/mono/sample/wasm/wasm.mk | 3 + src/mono/wasm/build/WasmApp.InTree.targets | 6 +- .../wasm/build/WasmApp.LocalBuild.targets | 4 +- src/mono/wasm/build/WasmApp.Native.targets | 54 ++-- src/mono/wasm/build/WasmApp.props | 13 +- src/mono/wasm/build/WasmApp.targets | 115 +++++++-- .../aot-tests/ProxyProjectForAOTOnHelix.proj | 1 + .../wasm/debugger/tests/Directory.Build.props | 1 + .../tests/debugger-test/debugger-test.csproj | 1 + src/tasks/AotCompilerTask/MonoAOTCompiler.cs | 29 ++- src/tasks/WasmAppBuilder/EmccCompile.cs | 17 +- .../WasmAppBuilder/PInvokeTableGenerator.cs | 38 ++- src/tasks/WasmAppBuilder/WasmAppBuilder.cs | 8 +- .../WasmAppBuilder/WasmAppBuilder.csproj | 1 + .../BlazorWasmBuildPublishTests.cs | 234 ++++++++++++++++++ .../Wasm.Build.Tests/BlazorWasmTests.cs | 12 +- .../Wasm.Build.Tests/BuildAndRunAttribute.cs | 4 +- .../Wasm.Build.Tests/BuildPublishTests.cs | 158 ++++++++++++ .../Wasm.Build.Tests/BuildTestBase.cs | 34 ++- .../Wasm.Build.Tests/CommandResult.cs | 6 +- .../Wasm.Build.Tests/HelperExtensions.cs | 5 +- .../Wasm.Build.Tests/NativeBuildTests.cs | 9 +- .../Wasm.Build.Tests/NativeLibraryTests.cs | 1 - .../BlazorWasmRebuildTests.cs | 37 +++ .../FlagsChangeRebuildTest.cs | 3 +- .../NativeRebuildTestsBase.cs | 26 +- .../NoopNativeRebuildTest.cs | 3 +- .../ReferenceNewAssemblyRebuildTest.cs | 3 +- .../SimpleSourceChangeRebuildTest.cs | 3 +- .../SatelliteAssembliesTests.cs | 5 +- .../SharedBuildPerTestClassFixture.cs | 15 +- .../Wasm.Build.Tests/Wasm.Build.Tests.csproj | 3 +- .../WasmNativeDefaultsTests.cs | 101 ++++++++ .../data/Local.Directory.Build.props | 4 - .../data/Local.Directory.Build.targets | 6 - .../data/Workloads.Directory.Build.targets | 7 - .../wasm-test-runner/WasmTestRunner.proj | 5 +- .../WebAssembly.Browser.HotReload.Test.csproj | 5 +- ...Assembly.Browser.RuntimeConfig.Test.csproj | 8 +- .../WebAssembly/Directory.Build.targets | 7 - 47 files changed, 865 insertions(+), 199 deletions(-) create mode 100644 src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs create mode 100644 src/tests/BuildWasmApps/Wasm.Build.Tests/BuildPublishTests.cs create mode 100644 src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/BlazorWasmRebuildTests.cs create mode 100644 src/tests/BuildWasmApps/Wasm.Build.Tests/WasmNativeDefaultsTests.cs diff --git a/eng/testing/scenarios/BuildWasmAppsJobsList.txt b/eng/testing/scenarios/BuildWasmAppsJobsList.txt index ba322274dfe62..9f0ea66754e2e 100644 --- a/eng/testing/scenarios/BuildWasmAppsJobsList.txt +++ b/eng/testing/scenarios/BuildWasmAppsJobsList.txt @@ -1,14 +1,18 @@ -BlazorWasmTests -FlagsChangeRebuildTest -InvariantGlobalizationTests -LocalEMSDKTests -MainWithArgsTests -NativeBuildTests -NativeLibraryTests -NoopNativeRebuildTest -RebuildTests -ReferenceNewAssemblyRebuildTest -SatelliteAssembliesTests -SimpleSourceChangeRebuildTest -WasmBuildAppTest -WorkloadTests +Wasm.Build.NativeRebuild.Tests.BlazorWasmRebuildTest +Wasm.Build.NativeRebuild.Tests.FlagsChangeRebuildTest +Wasm.Build.NativeRebuild.Tests.NoopNativeRebuildTest +Wasm.Build.NativeRebuild.Tests.ReferenceNewAssemblyRebuildTest +Wasm.Build.NativeRebuild.Tests.SimpleSourceChangeRebuildTest +Wasm.Build.Tests.BlazorWasmBuildPublishTests +Wasm.Build.Tests.BlazorWasmTests +Wasm.Build.Tests.BuildPublishTests +Wasm.Build.Tests.InvariantGlobalizationTests +Wasm.Build.Tests.LocalEMSDKTests +Wasm.Build.Tests.MainWithArgsTests +Wasm.Build.Tests.NativeBuildTests +Wasm.Build.Tests.NativeLibraryTests +Wasm.Build.Tests.RebuildTests +Wasm.Build.Tests.SatelliteAssembliesTests +Wasm.Build.Tests.WasmBuildAppTest +Wasm.Build.Tests.WasmNativeDefaultsTests +Wasm.Build.Tests.WorkloadTests diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index fc196e0053efb..eab1790ec927f 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -7,6 +7,7 @@ true BundleTestAppleApp;BundleTestAndroidApp + Publish @@ -291,7 +292,7 @@ + DependsOnTargets="$(PublishTestAsSelfContainedDependsOn);$(BundleTestAppTargets);ArchiveTests" /> + true + true $(BundleTestAppTargets);BundleTestWasmApp true + + + + true - WasmBuildApp - $(BundleTestWasmAppDependsOn);_BundleAOTTestWasmAppForHelix + + + PrepareForWasmBuildApp;$(WasmNestedPublishAppDependsOn) @@ -80,6 +92,8 @@ $([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) + + @@ -154,7 +168,7 @@ - + <_CopyLocalPaths diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 14ea741c8c595..6a917e00893a6 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -417,8 +417,8 @@ $(_BuildWasmAppsPayloadArchive) - set "HELIX_XUNIT_ARGS=-class Wasm.Build.Tests.%(Identity)" - export "HELIX_XUNIT_ARGS=-class Wasm.Build.Tests.%(Identity)" + set "HELIX_XUNIT_ARGS=-class %(Identity)" + export "HELIX_XUNIT_ARGS=-class %(Identity)" $(HelixCommand) $(_workItemTimeout) diff --git a/src/mono/sample/mbr/browser/WasmDelta.csproj b/src/mono/sample/mbr/browser/WasmDelta.csproj index 322a01ba8595a..c150529f753c6 100644 --- a/src/mono/sample/mbr/browser/WasmDelta.csproj +++ b/src/mono/sample/mbr/browser/WasmDelta.csproj @@ -31,7 +31,6 @@ - \%(_DeltaFileForPublish.Filename)%(_DeltaFileForPublish.Extension) diff --git a/src/mono/sample/wasm/Directory.Build.targets b/src/mono/sample/wasm/Directory.Build.targets index 492c61cf04846..bc7f6b24b0ba2 100644 --- a/src/mono/sample/wasm/Directory.Build.targets +++ b/src/mono/sample/wasm/Directory.Build.targets @@ -1,10 +1,5 @@ - - - - - Main(string[] args) } return args.Length; } -} \ No newline at end of file +} diff --git a/src/mono/sample/wasm/wasm.mk b/src/mono/sample/wasm/wasm.mk index 2eb4adcfb4585..a40a367831464 100644 --- a/src/mono/sample/wasm/wasm.mk +++ b/src/mono/sample/wasm/wasm.mk @@ -13,6 +13,9 @@ WASM_DEFAULT_BUILD_ARGS?=/p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Confi all: build build: + EMSDK_PATH=$(realpath $(TOP)/src/mono/wasm/emsdk) $(DOTNET) build $(DOTNET_Q_ARGS) $(WASM_DEFAULT_BUILD_ARGS) $(MSBUILD_ARGS) $(PROJECT_NAME) + +publish: EMSDK_PATH=$(realpath $(TOP)/src/mono/wasm/emsdk) $(DOTNET) publish $(DOTNET_Q_ARGS) $(WASM_DEFAULT_BUILD_ARGS) $(MSBUILD_ARGS) $(PROJECT_NAME) clean: diff --git a/src/mono/wasm/build/WasmApp.InTree.targets b/src/mono/wasm/build/WasmApp.InTree.targets index b345da95cf93c..0cc7e857a5afd 100644 --- a/src/mono/wasm/build/WasmApp.InTree.targets +++ b/src/mono/wasm/build/WasmApp.InTree.targets @@ -17,7 +17,7 @@ Condition="'$(_LocalMicrosoftNetCoreAppRuntimePackDir)' != '' and '%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" /> - + @@ -35,9 +35,9 @@ + DependsOnTargets="WasmTriggerPublishApp"> $(MSBuildProjectName) diff --git a/src/mono/wasm/build/WasmApp.LocalBuild.targets b/src/mono/wasm/build/WasmApp.LocalBuild.targets index 23f5249786d66..47559bccb8428 100644 --- a/src/mono/wasm/build/WasmApp.LocalBuild.targets +++ b/src/mono/wasm/build/WasmApp.LocalBuild.targets @@ -25,7 +25,7 @@ - true + true link @@ -45,7 +45,7 @@ Condition="'$(MicrosoftNetCoreAppRuntimePackLocationToUse)' != '' and '%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" /> - + diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets index 5b43374ab16b7..7e9c63c9c7900 100644 --- a/src/mono/wasm/build/WasmApp.Native.targets +++ b/src/mono/wasm/build/WasmApp.Native.targets @@ -17,12 +17,6 @@ _CompleteWasmBuildNative - - _InitializeCommonProperties; - _PrepareForWasmBuildNativeOnly; - _WasmBuildNativeCore; - - <_BeforeWasmBuildAppDependsOn> $(_BeforeWasmBuildAppDependsOn); _SetupEmscripten; @@ -39,16 +33,6 @@ - - - - - - <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" /> - <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" /> - - - <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenSdkToolsPath)' == '' or !Exists('$(EmscriptenSdkToolsPath)'))">%24(EmscriptenSdkToolsPath)=$(EmscriptenSdkToolsPath) @@ -117,11 +101,27 @@ - + + + + true + + true + false + + + + + true true - false - true + + + false + + + true + false @@ -152,7 +152,7 @@ <_WasmPInvokeHPath>$(_WasmRuntimePackIncludeDir)wasm\pinvoke.h <_DriverGenCPath>$(_WasmIntermediateOutputPath)driver-gen.c - <_DriverGenCNeeded Condition="'$(_DriverGenCNeeded)' == '' and '$(RunAOTCompilation)' == 'true'">true + <_DriverGenCNeeded Condition="'$(_DriverGenCNeeded)' == '' and '$(_WasmShouldAOT)' == 'true'">true <_EmccAssertionLevelDefault>0 <_EmccOptimizationFlagDefault Condition="'$(_WasmDevel)' == 'true'">-O0 -s ASSERTIONS=$(_EmccAssertionLevelDefault) @@ -190,8 +190,8 @@ <_EmccCFlags Include="$(EmccCompileOptimizationFlag)" /> <_EmccCFlags Include="@(_EmccCommonFlags)" /> - <_EmccCFlags Include="-DENABLE_AOT=1" Condition="'$(RunAOTCompilation)' == 'true'" /> - <_EmccCFlags Include="-DDRIVER_GEN=1" Condition="'$(RunAOTCompilation)' == 'true'" /> + <_EmccCFlags Include="-DENABLE_AOT=1" Condition="'$(_WasmShouldAOT)' == 'true'" /> + <_EmccCFlags Include="-DDRIVER_GEN=1" Condition="'$(_WasmShouldAOT)' == 'true'" /> <_EmccCFlags Include="-DINVARIANT_GLOBALIZATION=1" Condition="'$(InvariantGlobalization)' == 'true'" /> <_EmccCFlags Include="-DLINK_ICALLS=1" Condition="'$(WasmLinkIcalls)' == 'true'" /> <_EmccCFlags Include="-DCORE_BINDINGS" /> @@ -282,7 +282,7 @@ @@ -358,7 +358,7 @@ - + $(EmccExtraCFlags) -DDRIVER_GEN=1 <_DriverGenCNeeded>true @@ -414,7 +414,7 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ ******************************* --> - + <_MonoAotCrossCompilerPath>@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier','browser-wasm')) @@ -461,7 +461,7 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ <_WasmDedupAssembly>$(_WasmIntermediateOutputPath)\aot-instances.dll - + - + <_WasmStrippedAssembliesPath>$([MSBuild]::NormalizeDirectory($(_WasmIntermediateOutputPath), 'stripped-assemblies')) diff --git a/src/mono/wasm/build/WasmApp.props b/src/mono/wasm/build/WasmApp.props index bc45a6d54d73d..7fdde27c4affb 100644 --- a/src/mono/wasm/build/WasmApp.props +++ b/src/mono/wasm/build/WasmApp.props @@ -5,8 +5,7 @@ browser-wasm true - Publish - + <_WasmBuildCoreDependsOn> _InitializeCommonProperties; _BeforeWasmBuildApp; _WasmResolveReferences; @@ -15,6 +14,16 @@ _WasmBuildNativeCore; _WasmGenerateAppBundle; _AfterWasmBuildApp + + + + _PrepareForAfterBuild; + $(_WasmBuildCoreDependsOn) + + + _PrepareForNestedPublish; + $(_WasmBuildCoreDependsOn) + diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index e5ceb13def292..4ae7294ae528a 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -5,8 +5,8 @@ + true + <_WasmTriggerPublishAppAfterThisTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish + <_WasmNestedPublishAppPreTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish + + true - + + + - - + + + + - + + + + + + + + + + + + + + + + + + + + + <_WasmRuntimeConfigFilePath Condition="$([System.String]::new(%(PublishItemsOutputGroupOutputs.Identity)).EndsWith('$(AssemblyName).runtimeconfig.json'))">@(PublishItemsOutputGroupOutputs) + + + + + + + + + + <_WasmRuntimeConfigFilePath Condition="$([System.String]::new(%(PublishItemsOutputGroupOutputs.Identity)).EndsWith('$(AssemblyName).runtimeconfig.json'))">@(PublishItemsOutputGroupOutputs) + + + + + + + $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include')) <_WasmRuntimePackSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src')) - <_WasmIntermediateOutputPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm')) + <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForPublish)' == ''">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'relink')) + <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForPublish)' != ''">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'for-publish')) <_DriverGenCPath>$(_WasmIntermediateOutputPath)driver-gen.c + <_WasmShouldAOT Condition="'$(WasmBuildingForPublish)' == 'true' and '$(RunAOTCompilation)' == 'true'">true + <_WasmShouldAOT Condition="'$(RunAOTCompilationAfterBuild)' == 'true' and '$(RunAOTCompilation)' == 'true'">true + <_WasmShouldAOT Condition="'$(_WasmShouldAOT)' == ''">false + + + + + + - true + true + false $([MSBuild]::NormalizeDirectory($(OutputPath), 'AppBundle')) $(TargetFileName) $([MSBuild]::NormalizeDirectory($(WasmAppDir))) <_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll' and $(WasmGenerateAppBundle) == 'true'">%(WasmAssembliesToBundle.Identity) - <_WasmRuntimeConfigFilePath Condition="$(_MainAssemblyPath) != ''">$([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) - <_ParsedRuntimeConfigFilePath Condition="'$(_MainAssemblyPath)' != ''">$([System.IO.Path]::GetDirectoryName($(_MainAssemblyPath)))\runtimeconfig.bin + <_WasmRuntimeConfigFilePath Condition="'$(_WasmRuntimeConfigFilePath)' == '' and $(_MainAssemblyPath) != ''">$([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) + <_ParsedRuntimeConfigFilePath Condition="'$(_WasmRuntimeConfigFilePath)' != ''">$([System.IO.Path]::GetDirectoryName($(_WasmRuntimeConfigFilePath)))\runtimeconfig.bin - + + <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" /> <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" /> + <_WasmSatelliteAssemblies Remove="@(_WasmSatelliteAssemblies)" /> <_WasmSatelliteAssemblies Include="@(_WasmAssembliesInternal)" /> <_WasmSatelliteAssemblies Remove="@(_WasmSatelliteAssemblies)" Condition="!$([System.String]::Copy('%(Identity)').EndsWith('.resources.dll'))" /> @@ -166,9 +238,7 @@ - - - + icudt.dat @@ -184,7 +254,16 @@ + + + + + + + diff --git a/src/mono/wasm/data/aot-tests/ProxyProjectForAOTOnHelix.proj b/src/mono/wasm/data/aot-tests/ProxyProjectForAOTOnHelix.proj index 3a7b66fac7389..65a0df19fb640 100644 --- a/src/mono/wasm/data/aot-tests/ProxyProjectForAOTOnHelix.proj +++ b/src/mono/wasm/data/aot-tests/ProxyProjectForAOTOnHelix.proj @@ -5,6 +5,7 @@ $(MSBuildThisFileDirectory)..\wasm_build\ true + true $(TestRootDir)..\publish\ $(OriginalPublishDir)..\extraFiles\ $(TestRootDir)\obj\ diff --git a/src/mono/wasm/debugger/tests/Directory.Build.props b/src/mono/wasm/debugger/tests/Directory.Build.props index 0cff1f10a52d4..ff8864839daf1 100644 --- a/src/mono/wasm/debugger/tests/Directory.Build.props +++ b/src/mono/wasm/debugger/tests/Directory.Build.props @@ -4,6 +4,7 @@ $(AspNetCoreAppCurrent) Library + true Debug Release diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj index 0503feaaff07e..bf098dd83f578 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj @@ -5,6 +5,7 @@ true false PrepareForWasmBuildApp;$(WasmBuildAppDependsOn) + true diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index 71ae231a0fb04..b642f29ac0c19 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -931,23 +931,26 @@ public bool CopyOutputFileIfChanged() if (!_cache.Enabled) return true; - if (!File.Exists(TempFile)) - throw new LogAsErrorException($"Could not find output file {TempFile}"); - - if (!_cache.ShouldCopy(this, out string? cause)) + try { - _cache.Log.LogMessage(MessageImportance.Low, $"Skipping copying over {TargetFile} as the contents are unchanged"); - return false; - } + if (!_cache.ShouldCopy(this, out string? cause)) + { + _cache.Log.LogMessage(MessageImportance.Low, $"Skipping copying over {TargetFile} as the contents are unchanged"); + return false; + } - if (File.Exists(TargetFile)) - File.Delete(TargetFile); + if (File.Exists(TargetFile)) + File.Delete(TargetFile); - File.Copy(TempFile, TargetFile); - File.Delete(TempFile); + File.Copy(TempFile, TargetFile); - _cache.Log.LogMessage(MessageImportance.Low, $"Copying {TempFile} to {TargetFile} because {cause}"); - return true; + _cache.Log.LogMessage(MessageImportance.Low, $"Copying {TempFile} to {TargetFile} because {cause}"); + return true; + } + finally + { + File.Delete(TempFile); + } } } diff --git a/src/tasks/WasmAppBuilder/EmccCompile.cs b/src/tasks/WasmAppBuilder/EmccCompile.cs index e869e98e8564f..3d166670f14ac 100644 --- a/src/tasks/WasmAppBuilder/EmccCompile.cs +++ b/src/tasks/WasmAppBuilder/EmccCompile.cs @@ -44,6 +44,19 @@ public class EmccCompile : Microsoft.Build.Utilities.Task private int _numCompiled; public override bool Execute() + { + try + { + return ExecuteActual(); + } + catch (LogAsErrorException laee) + { + Log.LogError(laee.Message); + return false; + } + } + + private bool ExecuteActual() { if (SourceFiles.Length == 0) { @@ -211,7 +224,7 @@ bool ProcessSourceFile(string srcFile, string objFile) private bool ShouldCompile(string srcFile, string objFile, string[] depFiles, out string reason) { if (!File.Exists(srcFile)) - throw new ArgumentException($"Could not find source file {srcFile}"); + throw new LogAsErrorException($"Could not find source file {srcFile}"); if (!File.Exists(objFile)) { @@ -228,7 +241,7 @@ private bool ShouldCompile(string srcFile, string objFile, string[] depFiles, ou return true; } - reason = "everything is up-to-date."; + reason = "everything is up-to-date"; return false; bool IsNewerThanOutput(string inFile, string outFile, out string reason) diff --git a/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs b/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs index f6b89533f9863..bedd507f5115f 100644 --- a/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs +++ b/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs @@ -16,10 +16,10 @@ public class PInvokeTableGenerator : Task { - [Required] - public ITaskItem[]? Modules { get; set; } - [Required] - public ITaskItem[]? Assemblies { get; set; } + [Required, NotNull] + public string[]? Modules { get; set; } + [Required, NotNull] + public string[]? Assemblies { get; set; } [Required, NotNull] public string? OutputPath { get; set; } @@ -28,8 +28,28 @@ public class PInvokeTableGenerator : Task public override bool Execute() { - GenPInvokeTable(Modules!.Select(item => item.ItemSpec).ToArray(), Assemblies!.Select(item => item.ItemSpec).ToArray()); - return true; + if (Assemblies.Length == 0) + { + Log.LogError($"No assemblies given to scan for pinvokes"); + return false; + } + + if (Modules.Length == 0) + { + Log.LogError($"{nameof(PInvokeTableGenerator)}.{nameof(Modules)} cannot be empty"); + return false; + } + + try + { + GenPInvokeTable(Modules, Assemblies); + return !Log.HasLoggedErrors; + } + catch (LogAsErrorException laee) + { + Log.LogError(laee.Message); + return false; + } } public void GenPInvokeTable(string[] pinvokeModules, string[] assemblies) @@ -339,11 +359,7 @@ private static bool IsBlittable (Type type) return false; } - private static void Error (string msg) - { - // FIXME: - throw new Exception(msg); - } + private static void Error (string msg) => throw new LogAsErrorException(msg); } internal class PInvoke diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs index 57cb7c383f107..c0f1b08d05865 100644 --- a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs +++ b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs @@ -162,8 +162,12 @@ public override bool Execute () } FileCopyChecked(MainJS!, Path.Combine(AppDir, "runtime.js"), string.Empty); - var html = @""; - File.WriteAllText(Path.Combine(AppDir, "index.html"), html); + string indexHtmlPath = Path.Combine(AppDir, "index.html"); + if (!File.Exists(indexHtmlPath)) + { + var html = @""; + File.WriteAllText(indexHtmlPath, html); + } foreach (var assembly in _assemblies) { diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj b/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj index 3c93ab5d643ac..7c7377e5c427e 100644 --- a/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj +++ b/src/tasks/WasmAppBuilder/WasmAppBuilder.csproj @@ -15,6 +15,7 @@ + diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs new file mode 100644 index 0000000000000..c791f11b99d09 --- /dev/null +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -0,0 +1,234 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.IO; +using System.Linq; +using System.Xml; +using Xunit; +using Xunit.Abstractions; + +#nullable enable + +namespace Wasm.Build.Tests +{ + public class BlazorWasmBuildPublishTests : BuildTestBase + { + public BlazorWasmBuildPublishTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) + : base(output, buildContext) + { + _enablePerTestCleanup = true; + } + + [Theory] + [InlineData("Debug")] + [InlineData("Release")] + public void DefaultTemplate(string config) + { + string id = $"blz_no_aot_{config}"; + CreateTemplateProject(id); + + BlazorBuild(id, config, NativeFilesType.FromRuntimePack); + BlazorPublish(id, config, NativeFilesType.FromRuntimePack); + } + + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] + [InlineData("Debug")] + [InlineData("Release")] + public void DefaultTemplate_AOT_InProjectFile(string config) + { + string id = $"blz_aot_prj_file_{config}"; + string projectFile = CreateTemplateProject(id); + AddItemsPropertiesToProject(projectFile, extraProperties: "true"); + + // No relinking, no AOT + BlazorBuild(id, config, NativeFilesType.FromRuntimePack); + + // will aot + BlazorPublish(id, config, NativeFilesType.AOT); + + // build again + BlazorBuild(id, config, NativeFilesType.FromRuntimePack); + } + + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] + [InlineData("Debug")] + [InlineData("Release")] + public void DefaultTemplate_AOT_OnlyWithPublishCommandLine_Then_PublishNoAOT(string config) + { + string id = $"blz_aot_pub_{config}"; + CreateTemplateProject(id); + + // No relinking, no AOT + BlazorBuild(id, config, NativeFilesType.FromRuntimePack); + + // AOT=true only for the publish command line, similar to what + // would happen when setting it in Publish dialog for VS + BlazorPublish(id, config, expectedFileType: NativeFilesType.AOT, "-p:RunAOTCompilation=true"); + + // publish again, no AOT + BlazorPublish(id, config, NativeFilesType.Relinked); + } + + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] + [InlineData("Debug")] + [InlineData("Release")] + public void WithNativeReference_AOTInProjectFile(string config) + { + string id = $"blz_nativeref_aot_{config}"; + string projectFile = CreateProjectWithNativeReference(id); + AddItemsPropertiesToProject(projectFile, extraProperties: "true"); + + BlazorBuild(id, config, expectedFileType: NativeFilesType.Relinked); + + BlazorPublish(id, config, expectedFileType: NativeFilesType.AOT); + + // will relink + BlazorBuild(id, config, expectedFileType: NativeFilesType.Relinked); + } + + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] + [InlineData("Debug")] + [InlineData("Release")] + public void WithNativeReference_AOTOnCommandLine(string config) + { + string id = $"blz_nativeref_aot_{config}"; + string projectFile = CreateProjectWithNativeReference(id); + + BlazorBuild(id, config, expectedFileType: NativeFilesType.Relinked); + + BlazorPublish(id, config, expectedFileType: NativeFilesType.AOT, "-p:RunAOTCompilation=true"); + + // no aot! + BlazorPublish(id, config, expectedFileType: NativeFilesType.Relinked); + } + + private (CommandResult, string) BlazorBuild(string id, string config, NativeFilesType expectedFileType, params string[] extraArgs) + { + var res = BuildInternal(id, config, publish: false, extraArgs); + AssertDotNetNativeFiles(expectedFileType, config, forPublish: false); + + return res; + } + + private (CommandResult, string) BlazorPublish(string id, string config, NativeFilesType expectedFileType, params string[] extraArgs) + { + var res = BuildInternal(id, config, publish: true, extraArgs); + AssertDotNetNativeFiles(expectedFileType, config, forPublish: true); + return res; + } + + private (CommandResult, string) BuildInternal(string id, string config, bool publish=false, params string[] extraArgs) + { + string label = publish ? "publish" : "build"; + Console.WriteLine($"{Environment.NewLine}** {label} **{Environment.NewLine}"); + + string logPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-{label}.binlog"); + string[] combinedArgs = new[] + { + label, // same as the command name + $"-bl:{logPath}", + $"-p:Configuration={config}", + "-p:BlazorEnableCompression=false", + "-p:_WasmDevel=true" + }.Concat(extraArgs).ToArray(); + + CommandResult res = new DotNetCommand(s_buildEnv) + .WithWorkingDirectory(_projectDir!) + .ExecuteWithCapturedOutput(combinedArgs) + .EnsureSuccessful(); + + return (res, logPath); + } + + private void AssertDotNetNativeFiles(NativeFilesType type, string config, bool forPublish) + { + string label = forPublish ? "publish" : "build"; + string objBuildDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", forPublish ? "for-publish" : "relink"); + string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", forPublish ? "publish" : "", "wwwroot", "_framework"); + + string srcDir = type switch + { + NativeFilesType.FromRuntimePack => s_buildEnv.RuntimeNativeDir, + NativeFilesType.Relinked => objBuildDir, + NativeFilesType.AOT => objBuildDir, + _ => throw new ArgumentOutOfRangeException(nameof(type)) + }; + + AssertSameFile(Path.Combine(srcDir, "dotnet.wasm"), Path.Combine(binFrameworkDir, "dotnet.wasm"), label); + + // find dotnet*js + string? dotnetJsPath = Directory.EnumerateFiles(binFrameworkDir) + .Where(p => Path.GetFileName(p).StartsWith("dotnet.", StringComparison.OrdinalIgnoreCase) && + Path.GetFileName(p).EndsWith(".js", StringComparison.OrdinalIgnoreCase)) + .SingleOrDefault(); + + Assert.True(!string.IsNullOrEmpty(dotnetJsPath), $"[{label}] Expected to find dotnet*js in {binFrameworkDir}"); + AssertSameFile(Path.Combine(srcDir, "dotnet.js"), dotnetJsPath!, label); + + if (type != NativeFilesType.FromRuntimePack) + { + // check that the files are *not* from runtime pack + AssertNotSameFile(Path.Combine(s_buildEnv.RuntimeNativeDir, "dotnet.wasm"), Path.Combine(binFrameworkDir, "dotnet.wasm"), label); + AssertNotSameFile(Path.Combine(s_buildEnv.RuntimeNativeDir, "dotnet.js"), dotnetJsPath!, label); + } + } + + private string CreateProjectWithNativeReference(string id) + { + CreateTemplateProject(id); + + string extraItems = @$" + + + + + + "; + string projectFile = Path.Combine(_projectDir!, $"{id}.csproj"); + AddItemsPropertiesToProject(projectFile, extraItems: extraItems); + + return projectFile; + } + + private string CreateTemplateProject(string id) + { + InitBlazorWasmProjectDir(id); + new DotNetCommand(s_buildEnv, useDefaultArgs: false) + .WithWorkingDirectory(_projectDir!) + .ExecuteWithCapturedOutput("new blazorwasm") + .EnsureSuccessful(); + + return Path.Combine(_projectDir!, $"{id}.csproj"); + } + + private string AddItemsPropertiesToProject(string projectFile, string? extraProperties=null, string? extraItems=null) + { + if (extraProperties == null && extraItems == null) + return projectFile; + + XmlDocument doc = new(); + doc.Load(projectFile); + + if (extraItems != null) + { + XmlNode node = doc.CreateNode(XmlNodeType.Element, "ItemGroup", null); + node.InnerXml = extraItems; + doc.DocumentElement!.AppendChild(node); + } + + if (extraProperties != null) + { + XmlNode node = doc.CreateNode(XmlNodeType.Element, "PropertyGroup", null); + node.InnerXml = extraProperties; + doc.DocumentElement!.AppendChild(node); + } + + doc.Save(projectFile); + + return projectFile; + } + } + + internal enum NativeFilesType { FromRuntimePack, Relinked, AOT }; +} diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs index 9b7709098ed92..6d3312b5ce4f7 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs @@ -136,7 +136,7 @@ private void BuildNet50Project(string config, bool aot, bool expectError, string InitBlazorWasmProjectDir(id); string directoryBuildTargets = @" - + "; @@ -152,11 +152,11 @@ private void BuildNet50Project(string config, bool aot, bool expectError, string string publishLogPath = Path.Combine(logPath, $"{id}.binlog"); CommandResult result = new DotNetCommand(s_buildEnv) - .WithWorkingDirectory(_projectDir!) - .ExecuteWithCapturedOutput("publish", - $"-bl:{publishLogPath}", - (aot ? "-p:RunAOTCompilation=true" : ""), - $"-p:Configuration={config}"); + .WithWorkingDirectory(_projectDir!) + .ExecuteWithCapturedOutput("publish", + $"-bl:{publishLogPath}", + (aot ? "-p:RunAOTCompilation=true" : ""), + $"-p:Configuration={config}"); if (expectError) { diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildAndRunAttribute.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildAndRunAttribute.cs index c49b19517b3f2..8d6615332652c 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildAndRunAttribute.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildAndRunAttribute.cs @@ -34,9 +34,9 @@ public BuildAndRunAttribute(BuildArgs buildArgs, RunHost host = RunHost.All, par .UnwrapItemsAsArrays().ToList().Dump(); } - public BuildAndRunAttribute(bool aot=false, RunHost host = RunHost.All, params object?[] parameters) + public BuildAndRunAttribute(bool aot=false, RunHost host = RunHost.All, string? config=null, params object?[] parameters) { - _data = BuildTestBase.ConfigWithAOTData(aot) + _data = BuildTestBase.ConfigWithAOTData(aot, config) .Multiply(parameters) .WithRunHosts(host) .UnwrapItemsAsArrays().ToList().Dump(); diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildPublishTests.cs new file mode 100644 index 0000000000000..42eb96633f9b2 --- /dev/null +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildPublishTests.cs @@ -0,0 +1,158 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.IO; +using System.Linq; +using Wasm.Build.NativeRebuild.Tests; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +#nullable enable + +namespace Wasm.Build.Tests +{ + public class BuildPublishTests : NativeRebuildTestsBase + { + public BuildPublishTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) + : base(output, buildContext) + { + } + + [Theory] + [BuildAndRun(host: RunHost.V8, aot: false, config: "Release")] + [BuildAndRun(host: RunHost.V8, aot: false, config: "Debug")] + public void BuildThenPublishNoAOT(BuildArgs buildArgs, RunHost host, string id) + { + string projectName = $"build_publish_{buildArgs.Config}"; + + buildArgs = buildArgs with { ProjectName = projectName }; + buildArgs = ExpandBuildArgs(buildArgs); + + // no relinking for build + bool relinked = false; + BuildProject(buildArgs, + initProject: () => File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), s_mainReturns42), + dotnetWasmFromRuntimePack: !relinked, + id: id, + createProject: true, + publish: false); + + Run(); + + if (!_buildContext.TryGetBuildFor(buildArgs, out BuildProduct? product)) + throw new XunitException($"Test bug: could not get the build product in the cache"); + + File.Move(product!.LogFile, Path.ChangeExtension(product.LogFile!, ".first.binlog")); + + _testOutput.WriteLine($"{Environment.NewLine}Publishing with no changes ..{Environment.NewLine}"); + Console.WriteLine($"{Environment.NewLine}Publishing with no changes ..{Environment.NewLine}"); + + // relink by default for Release+publish + relinked = buildArgs.Config == "Release"; + BuildProject(buildArgs, + id: id, + dotnetWasmFromRuntimePack: !relinked, + createProject: false, + publish: true, + useCache: false); + + Run(); + + void Run() => RunAndTestWasmApp( + buildArgs, buildDir: _projectDir, expectedExitCode: 42, + test: output => {}, + host: host, id: id); + } + + [Theory] + [BuildAndRun(host: RunHost.V8, aot: true, config: "Release")] + [BuildAndRun(host: RunHost.V8, aot: true, config: "Debug")] + public void BuildThenPublishWithAOT(BuildArgs buildArgs, RunHost host, string id) + { + string projectName = $"build_publish_{buildArgs.Config}"; + + buildArgs = buildArgs with { ProjectName = projectName }; + buildArgs = ExpandBuildArgs(buildArgs, extraProperties: "<_WasmDevel>true"); + + // no relinking for build + bool relinked = false; + (_, string output) = BuildProject(buildArgs, + initProject: () => File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), s_mainReturns42), + dotnetWasmFromRuntimePack: !relinked, + id: id, + createProject: true, + publish: false, + label: "first_build"); + + BuildPaths paths = GetBuildPaths(buildArgs); + var pathsDict = GetFilesTable(buildArgs, paths, unchanged: false); + + string mainDll = $"{buildArgs.ProjectName}.dll"; + var firstBuildStat = StatFiles(pathsDict.Select(kvp => kvp.Value.fullPath)); + Assert.False(firstBuildStat["pinvoke.o"].Exists); + Assert.False(firstBuildStat[$"{mainDll}.bc"].Exists); + + CheckOutputForNativeBuild(expectAOT: false, expectRelinking: relinked, buildArgs, output); + + Run(expectAOT: false); + + if (!_buildContext.TryGetBuildFor(buildArgs, out BuildProduct? product)) + throw new XunitException($"Test bug: could not get the build product in the cache"); + + File.Move(product!.LogFile, Path.ChangeExtension(product.LogFile!, ".first.binlog")); + + _testOutput.WriteLine($"{Environment.NewLine}Publishing with no changes ..{Environment.NewLine}"); + Console.WriteLine($"{Environment.NewLine}Publishing with no changes ..{Environment.NewLine}"); + + // relink by default for Release+publish + (_, output) = BuildProject(buildArgs, + id: id, + dotnetWasmFromRuntimePack: false, + createProject: false, + publish: true, + useCache: false, + label: "first_publish"); + + var publishStat = StatFiles(pathsDict.Select(kvp => kvp.Value.fullPath)); + Assert.True(publishStat["pinvoke.o"].Exists); + Assert.True(publishStat[$"{mainDll}.bc"].Exists); + CheckOutputForNativeBuild(expectAOT: true, expectRelinking: false, buildArgs, output); + CompareStat(firstBuildStat, publishStat, pathsDict.Values); + + Run(expectAOT: true); + + // second build + (_, output) = BuildProject(buildArgs, + initProject: () => File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), s_mainReturns42), + dotnetWasmFromRuntimePack: !relinked, + id: id, + createProject: true, + publish: false, + label: "second_build"); + var secondBuildStat = StatFiles(pathsDict.Select(kvp => kvp.Value.fullPath)); + + // no relinking, or AOT + CheckOutputForNativeBuild(expectAOT: false, expectRelinking: false, buildArgs, output); + + // no native files changed + pathsDict.UpdateTo(unchanged: true); + CompareStat(publishStat, secondBuildStat, pathsDict.Values); + + void Run(bool expectAOT) => RunAndTestWasmApp( + buildArgs with { AOT = expectAOT }, + buildDir: _projectDir, expectedExitCode: 42, + host: host, id: id); + } + + void CheckOutputForNativeBuild(bool expectAOT, bool expectRelinking, BuildArgs buildArgs, string buildOutput) + { + AssertSubstring($"{buildArgs.ProjectName}.dll -> {buildArgs.ProjectName}.dll.bc", buildOutput, expectAOT); + AssertSubstring($"{buildArgs.ProjectName}.dll.bc -> {buildArgs.ProjectName}.dll.o", buildOutput, expectAOT); + + AssertSubstring("pinvoke.c -> pinvoke.o", buildOutput, expectRelinking || expectAOT); + } + + } +} diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index 50425f9844cb8..3030f8d852949 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -285,8 +285,11 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp bool useCache = true, bool expectSuccess = true, bool createProject = true, - string? verbosity=null) + bool publish = true, + string? verbosity=null, + string? label=null) { + string msgPrefix = label != null ? $"[{label}] " : string.Empty; if (useCache && _buildContext.TryGetBuildFor(buildArgs, out BuildProduct? product)) { Console.WriteLine ($"Using existing build found at {product.ProjectDir}, with build log at {product.LogFile}"); @@ -314,12 +317,13 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp } StringBuilder sb = new(); - sb.Append("publish"); + sb.Append(publish ? "publish" : "build"); sb.Append($" {s_buildEnv.DefaultBuildArgs}"); sb.Append($" /p:Configuration={buildArgs.Config}"); - string logFilePath = Path.Combine(_logPath, $"{buildArgs.ProjectName}.binlog"); + string logFileSuffix = label == null ? string.Empty : label.Replace(' ', '_'); + string logFilePath = Path.Combine(_logPath, $"{buildArgs.ProjectName}{logFileSuffix}.binlog"); _testOutput.WriteLine($"-------- Building ---------"); _testOutput.WriteLine($"Binlog path: {logFilePath}"); Console.WriteLine($"Binlog path: {logFilePath}"); @@ -384,7 +388,6 @@ static void AssertRuntimePackPath(string buildOutput) protected static void AssertBasicAppBundle(string bundleDir, string projectName, string config, bool hasIcudt=true, bool dotnetWasmFromRuntimePack=true) { - Console.WriteLine ($"AssertBasicAppBundle: {dotnetWasmFromRuntimePack}"); AssertFilesExist(bundleDir, new [] { "index.html", @@ -654,6 +657,29 @@ private static string GetEnvironmentVariableOrDefault(string envVarName, string return string.IsNullOrEmpty(value) ? defaultValue : value; } + internal BuildPaths GetBuildPaths(BuildArgs buildArgs, bool forPublish=true) + { + string objDir = GetObjDir(buildArgs.Config); + string bundleDir = Path.Combine(GetBinDir(baseDir: _projectDir, config: buildArgs.Config), "AppBundle"); + string wasmDir = Path.Combine(objDir, "wasm", forPublish ? "for-publish" : "relink"); + + return new BuildPaths(wasmDir, objDir, GetBinDir(buildArgs.Config), bundleDir); + } + + internal IDictionary StatFiles(IEnumerable fullpaths) + { + Dictionary table = new(); + foreach (string file in fullpaths) + { + if (File.Exists(file)) + table.Add(Path.GetFileName(file), new FileStat(FullPath: file, Exists: true, LastWriteTimeUtc: File.GetLastWriteTimeUtc(file), Length: new FileInfo(file).Length)); + else + table.Add(Path.GetFileName(file), new FileStat(FullPath: file, Exists: false, LastWriteTimeUtc: DateTime.MinValue, Length: 0)); + } + + return table; + } + protected static string s_mainReturns42 = @" public class TestClass { public static int Main() diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/CommandResult.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/CommandResult.cs index db95f8bab36c7..7372ef034bc08 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/CommandResult.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/CommandResult.cs @@ -24,10 +24,10 @@ public CommandResult(ProcessStartInfo startInfo, int exitCode, string output) Output = output; } - public void EnsureSuccessful(string messagePrefix = "", bool suppressOutput = false) + public CommandResult EnsureSuccessful(string messagePrefix = "", bool suppressOutput = false) => EnsureExitCode(0, messagePrefix, suppressOutput); - public void EnsureExitCode(int expectedExitCode = 0, string messagePrefix = "", bool suppressOutput = false) + public CommandResult EnsureExitCode(int expectedExitCode = 0, string messagePrefix = "", bool suppressOutput = false) { if (ExitCode != expectedExitCode) { @@ -43,6 +43,8 @@ public void EnsureExitCode(int expectedExitCode = 0, string messagePrefix = "", throw new XunitException(message.ToString()); } + + return this; } } } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/HelperExtensions.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/HelperExtensions.cs index a70a51bb10bbd..bff462f1f5de8 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/HelperExtensions.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/HelperExtensions.cs @@ -6,6 +6,7 @@ using System.Linq; using System.IO; using System.Text; +using System.Collections; #nullable enable @@ -96,7 +97,9 @@ public static class HelperExtensions public static void UpdateTo(this IDictionary dict, bool unchanged, params string[] filenames) { - foreach (var filename in filenames) + IEnumerable keys = filenames.Length == 0 ? dict.Keys.ToList() : filenames; + + foreach (var filename in keys) { if (!dict.TryGetValue(filename, out var oldValue)) { diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs index 80c7ba5fe85b8..315625db9483b 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs @@ -49,16 +49,17 @@ private void NativeBuild(string projectNamePrefix, string projectContents, Build public void IntermediateBitcodeToObjectFilesAreNotLLVMIR(BuildArgs buildArgs, string id) { string printFileTypeTarget = @" - + - + "; string projectName = $"bc_to_o_{buildArgs.Config}"; @@ -71,7 +72,7 @@ public void IntermediateBitcodeToObjectFilesAreNotLLVMIR(BuildArgs buildArgs, st dotnetWasmFromRuntimePack: false, id: id); - if (!output.Contains("wasm-dis exit code: 0")) + if (!output.Contains("** wasm-dis exit code: 0")) throw new XunitException($"Expected to successfully run wasm-dis on System.Private.CoreLib.dll.o ." + " It might fail if it was incorrectly compiled to a bitcode file, instead of wasm."); } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeLibraryTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeLibraryTests.cs index eb306286ba5e0..3ccf400ee9211 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeLibraryTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeLibraryTests.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.IO; using Xunit; using Xunit.Abstractions; diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/BlazorWasmRebuildTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/BlazorWasmRebuildTests.cs new file mode 100644 index 0000000000000..7401adfeac87e --- /dev/null +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/BlazorWasmRebuildTests.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Linq; +using Wasm.Build.Tests; +using Xunit; +using Xunit.Abstractions; + +#nullable enable + +namespace Wasm.Build.NativeRebuild.Tests +{ + public class BlazorWasmRebuildTests : NativeRebuildTestsBase + { + public BlazorWasmRebuildTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) + : base(output, buildContext) + { + } + + [Theory] + [MemberData(nameof(NativeBuildData))] + public void NoOpRebuild(BuildArgs buildArgs, bool nativeRelink, bool invariant, RunHost host, string id) + { + buildArgs = buildArgs with { ProjectName = $"rebuild_noop_{buildArgs.Config}" }; + (buildArgs, BuildPaths paths) = FirstNativeBuild(s_mainReturns42, nativeRelink: nativeRelink, invariant: invariant, buildArgs, id); + + var pathsDict = GetFilesTable(buildArgs, paths, unchanged: true); + var originalStat = StatFiles(pathsDict.Select(kvp => kvp.Value.fullPath)); + + Rebuild(nativeRelink, invariant, buildArgs, id); + var newStat = StatFiles(pathsDict.Select(kvp => kvp.Value.fullPath)); + + CompareStat(originalStat, newStat, pathsDict.Values); + RunAndTestWasmApp(buildArgs, buildDir: _projectDir, expectedExitCode: 42, host: host, id: id); + } + } +} diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/FlagsChangeRebuildTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/FlagsChangeRebuildTest.cs index 7ebc2d05cdd95..b73e521f8ca20 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/FlagsChangeRebuildTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/FlagsChangeRebuildTest.cs @@ -5,12 +5,13 @@ using System.IO; using System.Collections.Generic; using System.Linq; +using Wasm.Build.Tests; using Xunit; using Xunit.Abstractions; #nullable enable -namespace Wasm.Build.Tests +namespace Wasm.Build.NativeRebuild.Tests { public class FlagsChangeRebuildTest : NativeRebuildTestsBase { diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NativeRebuildTestsBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NativeRebuildTestsBase.cs index 2256fa58386ab..0e252fb064ef5 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NativeRebuildTestsBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NativeRebuildTestsBase.cs @@ -5,6 +5,7 @@ using System.IO; using System.Collections.Generic; using System.Linq; +using Wasm.Build.Tests; using Xunit; using Xunit.Abstractions; using Xunit.Sdk; @@ -12,7 +13,7 @@ #nullable enable -namespace Wasm.Build.Tests +namespace Wasm.Build.NativeRebuild.Tests { // TODO: test for runtime components public class NativeRebuildTestsBase : BuildTestBase @@ -136,29 +137,6 @@ internal void CompareStat(IDictionary oldStat, IDictionary StatFiles(IEnumerable fullpaths) - { - Dictionary table = new(); - foreach (string file in fullpaths) - { - if (File.Exists(file)) - table.Add(Path.GetFileName(file), new FileStat(FullPath: file, Exists: true, LastWriteTimeUtc: File.GetLastWriteTimeUtc(file), Length: new FileInfo(file).Length)); - else - table.Add(Path.GetFileName(file), new FileStat(FullPath: file, Exists: false, LastWriteTimeUtc: DateTime.MinValue, Length: 0)); - } - - return table; - } - - internal BuildPaths GetBuildPaths(BuildArgs buildArgs) - { - string objDir = GetObjDir(buildArgs.Config); - string bundleDir = Path.Combine(GetBinDir(baseDir: _projectDir, config: buildArgs.Config), "AppBundle"); - string wasmDir = Path.Combine(objDir, "wasm"); - - return new BuildPaths(wasmDir, objDir, GetBinDir(buildArgs.Config), bundleDir); - } - internal IDictionary GetFilesTable(BuildArgs buildArgs, BuildPaths paths, bool unchanged) { List files = new() diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NoopNativeRebuildTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NoopNativeRebuildTest.cs index 1ddbd4467b620..96f6d41fa1002 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NoopNativeRebuildTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NoopNativeRebuildTest.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Linq; +using Wasm.Build.Tests; using Xunit; using Xunit.Abstractions; #nullable enable -namespace Wasm.Build.Tests +namespace Wasm.Build.NativeRebuild.Tests { public class NoopNativeRebuildTest : NativeRebuildTestsBase { diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/ReferenceNewAssemblyRebuildTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/ReferenceNewAssemblyRebuildTest.cs index d908e287cf8bd..5aa3d2916f36f 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/ReferenceNewAssemblyRebuildTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/ReferenceNewAssemblyRebuildTest.cs @@ -3,12 +3,13 @@ using System.IO; using System.Linq; +using Wasm.Build.Tests; using Xunit; using Xunit.Abstractions; #nullable enable -namespace Wasm.Build.Tests +namespace Wasm.Build.NativeRebuild.Tests { public class ReferenceNewAssemblyRebuildTest : NativeRebuildTestsBase { diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/SimpleSourceChangeRebuildTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/SimpleSourceChangeRebuildTest.cs index 7f51447cb9e62..bbe7d60221671 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/SimpleSourceChangeRebuildTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/SimpleSourceChangeRebuildTest.cs @@ -3,12 +3,13 @@ using System.IO; using System.Linq; +using Wasm.Build.Tests; using Xunit; using Xunit.Abstractions; #nullable enable -namespace Wasm.Build.Tests +namespace Wasm.Build.NativeRebuild.Tests { public class SimpleSourceChangeRebuildTest : NativeRebuildTestsBase { diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/SatelliteAssembliesTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/SatelliteAssembliesTests.cs index 45ce2b37ed273..c3a40b470200a 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/SatelliteAssembliesTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/SatelliteAssembliesTests.cs @@ -40,12 +40,13 @@ public void ResourcesFromMainAssembly(BuildArgs buildArgs, string id) { string projectName = $"sat_asm_from_main_asm"; - bool dotnetWasmFromRuntimePack = !nativeRelink && !buildArgs.AOT; + // Release+publish defaults to native relinking + bool dotnetWasmFromRuntimePack = !nativeRelink && !buildArgs.AOT && buildArgs.Config != "Release"; buildArgs = buildArgs with { ProjectName = projectName }; buildArgs = ExpandBuildArgs(buildArgs, projectTemplate: s_resourcesProjectTemplate, - extraProperties: $"{(nativeRelink ? "true" : "false")}"); + extraProperties: nativeRelink ? $"true" : string.Empty); BuildProject(buildArgs, initProject: () => diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/SharedBuildPerTestClassFixture.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/SharedBuildPerTestClassFixture.cs index 03437e6730213..019391f3efaad 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/SharedBuildPerTestClassFixture.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/SharedBuildPerTestClassFixture.cs @@ -16,15 +16,20 @@ public class SharedBuildPerTestClassFixture : IDisposable public Dictionary _buildPaths = new(); public void CacheBuild(BuildArgs buildArgs, BuildProduct product) - => _buildPaths.Add(buildArgs, product); + { + if (product == null) + throw new ArgumentNullException(nameof(product)); + if (buildArgs == null) + throw new ArgumentNullException(nameof(buildArgs)); + _buildPaths.Add(buildArgs, product); + } public void RemoveFromCache(string buildPath, bool keepDir=true) { - KeyValuePair? foundKvp = _buildPaths.Where(kvp => kvp.Value.ProjectDir == buildPath).SingleOrDefault(); - if (foundKvp == null) - throw new Exception($"Could not find build path {buildPath} in cache to remove."); + BuildArgs? foundBuildArgs = _buildPaths.Where(kvp => kvp.Value.ProjectDir == buildPath).Select(kvp => kvp.Key).SingleOrDefault(); + if (foundBuildArgs is not null) + _buildPaths.Remove(foundBuildArgs); - _buildPaths.Remove(foundKvp.Value.Key); if (!keepDir) RemoveDirectory(buildPath); } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/Wasm.Build.Tests.csproj b/src/tests/BuildWasmApps/Wasm.Build.Tests/Wasm.Build.Tests.csproj index 7dacbc3ec26f7..6c9a7037025f6 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/Wasm.Build.Tests.csproj +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/Wasm.Build.Tests.csproj @@ -7,7 +7,6 @@ true BuildAndRun xunit - false true false TEST_DEBUG_CONFIG_ALSO @@ -18,7 +17,7 @@ true - + false diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmNativeDefaultsTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmNativeDefaultsTests.cs new file mode 100644 index 0000000000000..8880fd27b9d8c --- /dev/null +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmNativeDefaultsTests.cs @@ -0,0 +1,101 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.IO; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +#nullable enable + +namespace Wasm.Build.Tests +{ + public class WasmNativeDefaultsTests : BuildTestBase + { + public WasmNativeDefaultsTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) + : base(output, buildContext) + { + } + + [Theory] + /* relink by default for publish+Release */ + [InlineData("Release", "", /*aot*/ false, /*build*/ false, /*publish*/ true)] + /* NO relink by default for publish+Release, even when not trimming */ + [InlineData("Release", "false", /*aot*/ false, /*build*/ false, /*publish*/ false)] + + [InlineData("Debug", "", /*aot*/ false, /*build*/ false, /*publish*/ false)] + + /* AOT */ + [InlineData("Release", "", /*aot*/ true, /*build*/ false, /*publish*/ true)] + [InlineData("Debug", "", /*aot*/ true, /*build*/ false, /*publish*/ true)] + // FIXME: separate test + // [InlineData("Release", "true", + // /*aot*/ true, /*build*/ true, /*publish*/ true)] + + /* AOT not affected by trimming */ + [InlineData("Release", "false", /*aot*/ true, /*build*/ false, /*publish*/ true)] + [InlineData("Debug", "false", /*aot*/ true, /*build*/ false, /*publish*/ true)] + public void Defaults(string config, string extraProperties, bool aot, bool buildValue, bool publishValue) + { + string output = CheckWasmNativeDefaultValue("native_defaults_publish", config, extraProperties, aot, dotnetWasmFromRuntimePack: !publishValue); + + Assert.Contains($"** WasmBuildNative: '{buildValue.ToString().ToLower()}', WasmBuildingForPublish: ''", output); + Assert.Contains($"** WasmBuildNative: '{publishValue.ToString().ToLower()}', WasmBuildingForPublish: 'true'", output); + Assert.Contains("Stopping the build", output); + } + + [Theory] + /* always relink */ + [InlineData("Release", "", /*build*/ true, /*publish*/ true)] + [InlineData("Debug", "", /*build*/ true, /*publish*/ true)] + [InlineData("Release", "false", /*build*/ true, /*publish*/ true)] + public void WithNativeReference(string config, string extraProperties, bool buildValue, bool publishValue) + { + string nativeLibPath = Path.Combine(BuildEnvironment.TestAssetsPath, "native-libs", "native-lib.o"); + string nativeRefItem = @$""; + string output = CheckWasmNativeDefaultValue("native_defaults_publish", + config, + extraProperties, + aot: false, + dotnetWasmFromRuntimePack: !publishValue, + extraItems: nativeRefItem); + + Assert.Contains($"** WasmBuildNative: '{buildValue.ToString().ToLower()}', WasmBuildingForPublish: ''", output); + Assert.Contains($"** WasmBuildNative: '{publishValue.ToString().ToLower()}', WasmBuildingForPublish: 'true'", output); + Assert.Contains("Stopping the build", output); + } + + private string CheckWasmNativeDefaultValue(string projectName, + string config, + string extraProperties, + bool aot, + bool dotnetWasmFromRuntimePack, + string extraItems = "") + { + // builds with -O0 + extraProperties += "<_WasmDevel>true"; + + string printValueTarget = @" + + + + "; + + BuildArgs buildArgs = new(ProjectName: projectName, Config: config, AOT: aot, string.Empty, null); + buildArgs = ExpandBuildArgs(buildArgs, + extraProperties: extraProperties, + extraItems: extraItems, + insertAtEnd: printValueTarget); + + (_, string output) = BuildProject(buildArgs, + initProject: () => File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), s_mainReturns42), + dotnetWasmFromRuntimePack: dotnetWasmFromRuntimePack, + id: Path.GetRandomFileName(), + expectSuccess: false, + useCache: false); + + return output; + } + } +} diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Local.Directory.Build.props b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Local.Directory.Build.props index 1a9c112e747d9..6d53e53b3bf55 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Local.Directory.Build.props +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Local.Directory.Build.props @@ -7,8 +7,4 @@ - - - PrepareForWasmBuild;$(WasmBuildAppDependsOn) - diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Local.Directory.Build.targets b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Local.Directory.Build.targets index 65f76e4fc8582..b327d1e91f6eb 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Local.Directory.Build.targets +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Local.Directory.Build.targets @@ -16,12 +16,6 @@ Text="%24(WasmMainJS) is set when %24(WasmGenerateAppBundle) is not true: it won't be used because an app bundle is not being generated. Possible build authoring error" /> - - - - - - diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Workloads.Directory.Build.targets b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Workloads.Directory.Build.targets index 105c0a74c0875..34eeeaeee7bd7 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Workloads.Directory.Build.targets +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Workloads.Directory.Build.targets @@ -1,15 +1,8 @@ - PrepareForWasmBuild;$(WasmBuildAppDependsOn) <_MicrosoftNetCoreAppRefDir>$(AppRefDir)\ - - - - - - diff --git a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj index 5f4d4f084d13b..e2eda44d7ffc0 100644 --- a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj +++ b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj @@ -10,14 +10,17 @@ $(MSBuildThisFileDirectory)\obj\$(Configuration)\wasm $(TestBinDir)/WasmApp/ 99.0 + true + true $(CORE_ROOT)\WasmAppBuilder\WasmAppBuilder.dll $(CORE_ROOT)\MonoAOTCompiler\MonoAOTCompiler.dll $(CORE_ROOT)\JsonToItemsTaskFactory\JsonToItemsTaskFactory.dll $(CORE_ROOT)\RuntimeConfigParser\RuntimeConfigParser.dll + BuildApp;$(WasmBuildAppDependsOn) - + $(TestAssemblyFileName) $(AppDir) diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/WebAssembly.Browser.HotReload.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/WebAssembly.Browser.HotReload.Test.csproj index 2ba05527c2a42..d9dbaa2ebd444 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/WebAssembly.Browser.HotReload.Test.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/WebAssembly.Browser.HotReload.Test.csproj @@ -16,13 +16,10 @@ Always + - - - - diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj index 4efa17aab45d9..35e9eec2cae87 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj @@ -5,13 +5,9 @@ 42 runtime.js - + + - - - - - diff --git a/src/tests/FunctionalTests/WebAssembly/Directory.Build.targets b/src/tests/FunctionalTests/WebAssembly/Directory.Build.targets index b0d320fabe377..802f2525e5880 100644 --- a/src/tests/FunctionalTests/WebAssembly/Directory.Build.targets +++ b/src/tests/FunctionalTests/WebAssembly/Directory.Build.targets @@ -2,13 +2,6 @@ - PrepareForWasmBuild;$(WasmBuildAppDependsOn) $(OutputPath)\$(Configuration)\AppBundle\ - - - - - - From cfb584ddd7ec9c0c736d227de94faf999c80727e Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 25 Aug 2021 04:11:12 -0400 Subject: [PATCH 02/46] Fix helix work item name --- src/libraries/sendtohelixhelp.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 6a917e00893a6..93cbb9aca5c90 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -415,7 +415,7 @@ - + $(_BuildWasmAppsPayloadArchive) set "HELIX_XUNIT_ARGS=-class %(Identity)" export "HELIX_XUNIT_ARGS=-class %(Identity)" From 80fe082ff58df4bc2926394fad4f65b4f2abe8f2 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 25 Aug 2021 04:12:33 -0400 Subject: [PATCH 03/46] fix test --- .../Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index c791f11b99d09..6977d3cadfe97 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -29,7 +29,15 @@ public void DefaultTemplate(string config) CreateTemplateProject(id); BlazorBuild(id, config, NativeFilesType.FromRuntimePack); - BlazorPublish(id, config, NativeFilesType.FromRuntimePack); + if (config == "Release") + { + // relinking in publish for Release config + BlazorPublish(id, config, NativeFilesType.Relinked); + } + else + { + BlazorPublish(id, config, NativeFilesType.FromRuntimePack); + } } [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] From b4d765980e43f9c148cf0ac5d4ece900e2039859 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 25 Aug 2021 11:40:22 -0400 Subject: [PATCH 04/46] get all the assemblies from the publishdir --- src/mono/wasm/build/WasmApp.targets | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 4ae7294ae528a..56e5a2ad45f17 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -87,7 +87,7 @@ true - <_WasmTriggerPublishAppAfterThisTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish + <_WasmTriggerPublishAppAfterThisTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true' and '$(WasmBuildingForPublish)' != 'true'">Publish <_WasmNestedPublishAppPreTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish true @@ -102,7 +102,7 @@ + Properties="_WasmInNestedPublish_UniqueProperty_XYZ=true;;WasmBuildingForPublish=true"> @@ -133,9 +133,8 @@ - - + From c39313b43b87391234f8e0723c498d2c218937f8 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 25 Aug 2021 23:07:28 -0400 Subject: [PATCH 05/46] AOTCompiler: Expand the paths used with MONO_PATH --- src/tasks/AotCompilerTask/MonoAOTCompiler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index b642f29ac0c19..8ec425fac8b66 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -373,7 +373,7 @@ public override bool Execute() private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths) { - string assembly = assemblyItem.ItemSpec; + string assembly = assemblyItem.GetMetadata("FullPath"); string assemblyDir = Path.GetDirectoryName(assembly)!; var aotAssembly = new TaskItem(assembly); var aotArgs = new List(); @@ -836,7 +836,7 @@ private IList ConvertAssembliesDictToOrderedList(ConcurrentDictionary List outItems = new(items.Length); foreach (ITaskItem item in items) { - if (!dict.TryGetValue(item.ItemSpec, out ITaskItem? dictItem)) + if (!dict.TryGetValue(item.GetMetadata("FullPath"), out ITaskItem? dictItem)) throw new LogAsErrorException($"Bug: Could not find item in the dict with key {item.ItemSpec}"); outItems.Add(dictItem); From f9948e5e02bec7c0e17cf810d3d3d2cd0b97c734 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 25 Aug 2021 23:07:48 -0400 Subject: [PATCH 06/46] Implement support for skipping assemblies for AOT --- src/mono/wasm/build/WasmApp.Native.targets | 21 +++++++++------------ src/mono/wasm/build/WasmApp.targets | 7 ++++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets index 7e9c63c9c7900..4a9fbbbab9ff5 100644 --- a/src/mono/wasm/build/WasmApp.Native.targets +++ b/src/mono/wasm/build/WasmApp.Native.targets @@ -433,13 +433,11 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ - <_AotInputAssemblies Include="@(_WasmAssembliesInternal)" Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'"> + <_AotInputAssemblies Include="@(_WasmAssembliesInternal)" Exclude="@(_AOT_AssembliesForceToInterpret)"> @(MonoAOTCompilerDefaultAotArguments, ';') @(MonoAOTCompilerDefaultProcessArguments, ';') - <_AOT_InternalForceInterpretAssemblies Include="@(_WasmAssembliesInternal->WithMetadataValue('_InternalForceInterpret', 'true'))" /> - <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" /> <_WasmAOTSearchPaths Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)" /> @@ -452,8 +450,8 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ <_AOTCompilerCacheFile>$(_WasmIntermediateOutputPath)aot_compiler_cache.json - + @@ -501,12 +499,11 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ - - <_WasmAssembliesInternal Include="@(_AOT_InternalForceInterpretAssemblies)" /> - - <_AOTAssemblies Include="@(_WasmAssembliesInternal)" Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'" /> <_BitcodeFile Include="%(_WasmAssembliesInternal.LlvmBitcodeFile)" /> <_BitcodeFile ObjectFile="$(_WasmIntermediateOutputPath)%(FileName).o" /> + + + <_WasmAssembliesInternal Include="@(_AOT_AssembliesForceToInterpret)" /> @@ -517,11 +514,11 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ + <_AOTedAssemblies Include="@(_WasmAssembliesInternal)" Exclude="@(_AOT_AssembliesForceToInterpret)" /> <_WasmStrippedAssemblies - Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'" - Include="@(_WasmAssembliesInternal->'$(_WasmStrippedAssembliesPath)%(FileName)%(Extension)')" + Include="@(_AOTedAssemblies)" OriginalPath="%(_WasmAssembliesInternal.Identity)" /> - <_WasmInterpOnlyAssembly Include="@(_WasmAssembliesInternal->WithMetadataValue('_InternalForceInterpret', 'true'))" /> + <_WasmInterpOnlyAssembly Include="@(_AOT_AssembliesForceToInterpret)" /> diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 56e5a2ad45f17..f9ae90547f2d0 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -6,9 +6,6 @@ Required public items/properties: - $(WasmMainJSPath) - - FIXME: %(_InternalForceInterpret) metadata - if true, then skips this assembly from the AOT step. - Error for this to be set with AOTMode=LLVMOnly - - $(EMSDK_PATH) - points to the emscripten sdk location. Public properties (optional): @@ -70,6 +67,10 @@ + + - @(_AOT_AssembliesForceToInterpret) - Assemblies to exclude from AOT + note: This is not compatible with AOTMode=LLVMOnly . + --> From 7a82a3f498523205228a033cd28538944ab42c48 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 26 Aug 2021 19:56:06 -0400 Subject: [PATCH 07/46] Update blazorwasm targets file with a locally patched copy --- src/libraries/workloads-testing.targets | 3 + src/mono/wasm/BlazorOverwrite.targets | 741 ++++++++++++++++++++++++ 2 files changed, 744 insertions(+) create mode 100644 src/mono/wasm/BlazorOverwrite.targets diff --git a/src/libraries/workloads-testing.targets b/src/libraries/workloads-testing.targets index 3e668a38c2400..01464b7224831 100644 --- a/src/libraries/workloads-testing.targets +++ b/src/libraries/workloads-testing.targets @@ -16,6 +16,8 @@ + + @@ -39,6 +41,7 @@ + diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets new file mode 100644 index 0000000000000..ced77c3303efa --- /dev/null +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -0,0 +1,741 @@ + + + + + true + + + true + + + + + $(MSBuildThisFileDirectory)..\ + <_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">net6.0 + <_BlazorWebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' != 'Core'">net472 + <_BlazorWebAssemblySdkTasksAssembly>$(BlazorWebAssemblySdkDirectoryRoot)tools\$(_BlazorWebAssemblySdkTasksTFM)\Microsoft.NET.Sdk.BlazorWebAssembly.Tasks.dll + <_BlazorWebAssemblySdkToolAssembly>$(BlazorWebAssemblySdkDirectoryRoot)tools\net6.0\Microsoft.NET.Sdk.BlazorWebAssembly.Tool.dll + + + + + + + + + + + + + true + true + + + false + false + true + false + false + false + <_AggressiveAttributeTrimming Condition="'$(_AggressiveAttributeTrimming)' == ''">true + false + true + + + false + false + false + false + true + + + false + + <_TargetingNET60OrLater Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '6.0'))">true + + + + false + + true + true + false + ComputeFilesToPublish;_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn) + + + + + + + + + + + + $(ResolveStaticWebAssetsInputsDependsOn); + _AddBlazorWasmStaticWebAssets; + + + + _GenerateBuildBlazorBootJson; + $(StaticWebAssetsPrepareForRunDependsOn) + + + + $(ResolvePublishStaticWebAssetsDependsOn); + ProcessPublishFilesForBlazor; + ComputeBlazorExtensions; + _AddPublishBlazorBootJsonToStaticWebAssets; + + + + $(GenerateStaticWebAssetsPublishManifestDependsOn); + GeneratePublishBlazorBootJson; + + + + + + + + + + <_DotNetJsVersion>$(BundledNETCoreAppPackageVersion) + <_DotNetJsVersion Condition="'$(RuntimeFrameworkVersion)' != ''">$(RuntimeFrameworkVersion) + <_BlazorDotnetJsFileName>dotnet.$(_DotNetJsVersion).js + + + + + <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'"> + _framework/$(_BlazorDotnetJsFileName) + native + true + + + + + + + + + + + + + <_DotnetJsStaticWebAsset Include="@(_DotnetJsStaticWebAssetCandidate->'%(ContentRoot)_framework\dotnet.js')" /> + <_BlazorStaticWebAsset Include="@(_DotnetJsStaticWebAsset)" /> + + + + + + + <_DotNetJsVersion>$(BundledNETCoreAppPackageVersion) + <_DotNetJsVersion Condition="'$(RuntimeFrameworkVersion)' != ''">$(RuntimeFrameworkVersion) + <_BlazorDotnetJsFileName>dotnet.$(_DotNetJsVersion).js + + + + <_DotNetJsItem Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.DestinationSubPath)' == 'dotnet.js' AND '%(ReferenceCopyLocalPaths.AssetType)' == 'native'"> + _framework/$(_BlazorDotnetJsFileName) + + + + + <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'"> + _framework/$(_BlazorDotnetJsFileName) + native + true + + + + + + + + + + + + + <_DotnetJsStaticWebAsset Include="@(_DotnetJsStaticWebAssetCandidate->'%(ContentRoot)_framework\dotnet.js')" /> + <_BlazorStaticWebAsset Include="@(_DotnetJsStaticWebAsset)" /> + + + + + + + + + + + + + + <_BlazorEnableTimeZoneSupport>$(BlazorEnableTimeZoneSupport) + <_BlazorEnableTimeZoneSupport Condition="'$(_BlazorEnableTimeZoneSupport)' == ''">true + <_BlazorInvariantGlobalization>$(InvariantGlobalization) + <_BlazorInvariantGlobalization Condition="'$(_BlazorInvariantGlobalization)' == ''">true + <_BlazorCopyOutputSymbolsToOutputDirectory>$(CopyOutputSymbolsToOutputDirectory) + <_BlazorCopyOutputSymbolsToOutputDirectory Condition="'$(_BlazorCopyOutputSymbolsToOutputDirectory)'==''">true + + + + + $(OutputPath)$(PublishDirName)\ + + <_BlazorWebAssemblyLoadAllGlobalizationData>$(BlazorWebAssemblyLoadAllGlobalizationData) + <_BlazorWebAssemblyLoadAllGlobalizationData Condition="'$(_BlazorWebAssemblyLoadAllGlobalizationData)' == ''">false + + + + <_BlazorJSFile Include="$(BlazorWebAssemblyJSPath)" /> + <_BlazorJSFile Include="$(BlazorWebAssemblyJSMapPath)" Condition="Exists('$(BlazorWebAssemblyJSMapPath)')" /> + <_BlazorJsFile> + _framework/%(Filename)%(Extension) + + + + + + <_BlazorConfigFileCandidates Include="@(StaticWebAsset)" Condition="'%(SourceType)' == 'Discovered'" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_BlazorBuildGZipCompressDirectory>$(IntermediateOutputPath)build-gz\ + + + + + <_GzipFileToCompressForBuild Include="@(_BlazorStaticWebAsset->'%(OriginalItemSpec)')" > + %(Identity) + Alternative + Content-Encoding + gzip + + + + + + + + + + + <_BlazorBuildGZipCompressedFile> + %(RelatedAsset) + + + <_BlazorGzipStaticWebAsset Include="@(_BlazorBuildGZipCompressedFile->'%(FullPath)')" /> + + + + <_BlazorBuildBootJsonPath>$(IntermediateOutputPath)blazor.boot.json + + + + <_BuildBlazorBootJson + Include="$(_BlazorBuildBootJsonPath)" + RelativePath="_framework/blazor.boot.json" /> + + + + + + + + + + + + + + + + + + + + <_BlazorBuildBootJsonPath>$(IntermediateOutputPath)blazor.boot.json + <_BlazorWebAssemblyLoadAllGlobalizationData Condition="'$(BlazorWebAssemblyLoadAllGlobalizationData)' == ''">false + + + + <_BlazorJsModuleCandidatesForBuild + Include="@(StaticWebAsset)" + Condition="'%(StaticWebAsset.AssetTraitName)' == 'JSModule' and '%(StaticWebAsset.AssetTraitValue)' == 'JSLibraryModule' and '%(AssetKind)' != 'Publish'" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_BlazorTypeGranularTrimmerDescriptorFile>$(IntermediateOutputPath)typegranularity.trimmerdescriptor.xml + + + + <_BlazorTypeGranularAssembly + Include="@(ManagedAssemblyToLink)" + Condition="'%(Extension)' == '.dll' AND $([System.String]::Copy('%(Filename)').StartsWith('Microsoft.AspNetCore.'))"> + false + all + + + + + + + + + + + + + + + + + + + $(OutputPath)$(PublishDirName)\ + + <_BlazorEnableTimeZoneSupport>$(BlazorEnableTimeZoneSupport) + <_BlazorEnableTimeZoneSupport Condition="'$(_BlazorEnableTimeZoneSupport)' == ''">true + <_BlazorInvariantGlobalization>$(InvariantGlobalization) + <_BlazorInvariantGlobalization Condition="'$(_BlazorInvariantGlobalization)' == ''">true + <_BlazorAotEnabled>$(UsingBrowserRuntimeWorkload) + <_BlazorAotEnabled Condition="'$(_BlazorAotEnabled)' == ''">false + <_BlazorLinkerEnabled>$(PublishTrimmed) + <_BlazorLinkerEnabled Condition="'$(_BlazorLinkerEnabled)' == ''">true + + + + + + + + + + <_BlazorPublishPrefilteredAssets + Include="@(StaticWebAsset)" + Condition="'%(StaticWebAsset.AssetTraitName)' == 'BlazorWebAssemblyResource' or '%(StaticWebAsset.AssetTraitName)' == 'Culture' or '%(AssetRole)' == 'Alternative'" /> + + + + + + + + + + + + + + + + + <_BlazorExtensionsCandidate Include="@(BlazorPublishExtension->'%(FullPath)')"> + $(PackageId) + Computed + $(PublishDir)wwwroot + $(StaticWebAssetBasePath) + %(BlazorPublishExtension.RelativePath) + Publish + All + Primary + BlazorWebAssemblyResource + extension:%(BlazorPublishExtension.ExtensionName) + Never + PreserveNewest + %(BlazorPublishExtension.Identity) + + + + + + + + + + + + + + + + + + + <_PublishBlazorBootJson + Include="$(IntermediateOutputPath)blazor.publish.boot.json" + RelativePath="_framework/blazor.boot.json" /> + + + + + + + + + + + <_BlazorPublishAsset + Include="@(StaticWebAsset)" + Condition="'%(AssetKind)' != 'Build' and '%(StaticWebAsset.AssetTraitValue)' != 'manifest' and ('%(StaticWebAsset.AssetTraitName)' == 'BlazorWebAssemblyResource' or '%(StaticWebAsset.AssetTraitName)' == 'Culture') and '%(StaticWebAsset.AssetTraitValue)' != 'boot'" /> + + <_BlazorPublishConfigFile + Include="@(StaticWebAsset)" + Condition="'%(StaticWebAsset.AssetTraitName)' == 'BlazorWebAssemblyResource' and '%(StaticWebAsset.AssetTraitValue)' == 'settings'"/> + + <_BlazorJsModuleCandidatesForPublish + Include="@(StaticWebAsset)" + Condition="'%(StaticWebAsset.AssetTraitName)' == 'JSModule' and '%(StaticWebAsset.AssetTraitValue)' == 'JSLibraryModule' and '%(AssetKind)' != 'Build'" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_CompressedFileOutputPath>$(IntermediateOutputPath)compress\ + <_BlazorWebAssemblyBrotliIncremental>true + + + + <_DotNetHostDirectory>$(NetCoreRoot) + <_DotNetHostFileName>dotnet + <_DotNetHostFileName Condition="'$(OS)' == 'Windows_NT'">dotnet.exe + + + + + + + + <_GzipFileToCompressForPublish Include="@(StaticWebAsset)" + Condition="'%(AssetKind)' != 'Build' and ('%(StaticWebAsset.AssetTraitName)' == 'BlazorWebAssemblyResource' or '%(StaticWebAsset.AssetTraitName)' == 'Culture')" > + %(Identity) + Alternative + Content-Encoding + gzip + + + <_BrotliFileToCompressForPublish Include="@(_GzipFileToCompressForPublish)" Condition="'%(AssetKind)' != 'Build'"> + br + + + + <_AlreadyGzipCompressedAssets + Include="@(StaticWebAsset)" + Condition="'%(AssetKind)' != 'Build' and ('%(StaticWebAsset.AssetTraitName)' == 'Content-Encoding' and '%(StaticWebAsset.AssetTraitValue)' == 'gzip')" /> + <_GzipFileToCompressForPublish Remove="@(_AlreadyGzipCompressedAssets->'%(RelatedAsset)')" /> + + + + + + + + + + + + + + + + <_BlazorPublishGZipCompressedFile> + %(RelatedAsset) + + <_BlazorPublishBrotliCompressedFile> + %(RelatedAsset) + + + + + + + + From cd9ec8ef48fe806080b43f99ede5941268e25009 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 26 Aug 2021 19:56:19 -0400 Subject: [PATCH 08/46] Cleanup --- src/libraries/workloads-testing.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/workloads-testing.targets b/src/libraries/workloads-testing.targets index 01464b7224831..310a6f0cc166f 100644 --- a/src/libraries/workloads-testing.targets +++ b/src/libraries/workloads-testing.targets @@ -6,7 +6,7 @@ - + @@ -25,7 +25,7 @@ - + From 8944a9803e5f0c97d728cd50facd2c5457861291 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 26 Aug 2021 23:34:09 -0400 Subject: [PATCH 09/46] fix path for copying blazorwasm targets file --- src/libraries/workloads-testing.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/workloads-testing.targets b/src/libraries/workloads-testing.targets index 310a6f0cc166f..d3dc57267a608 100644 --- a/src/libraries/workloads-testing.targets +++ b/src/libraries/workloads-testing.targets @@ -16,7 +16,7 @@ - + @@ -41,7 +41,7 @@ - + From 56c5dc353ee9a36910d771424cb84f52eee368f8 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 26 Aug 2021 23:45:48 -0400 Subject: [PATCH 10/46] Fix tests on emsdk --- .../Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index 6977d3cadfe97..d6b8acb5e1f40 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -202,6 +202,13 @@ private string CreateProjectWithNativeReference(string id) private string CreateTemplateProject(string id) { InitBlazorWasmProjectDir(id); + if (IsNotUsingWorkloads) + { + // no packs installed, so no need to update the paths for runtime pack etc + File.WriteAllText(Path.Combine(_projectDir!, "Directory.Build.props"), ""); + File.WriteAllText(Path.Combine(_projectDir!, "Directory.Build.targets"), ""); + } + new DotNetCommand(s_buildEnv, useDefaultArgs: false) .WithWorkingDirectory(_projectDir!) .ExecuteWithCapturedOutput("new blazorwasm") From 5c707f08f3b45c970f38202331cf679ecaad37d2 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 27 Aug 2021 11:29:33 -0400 Subject: [PATCH 11/46] Don't fixup runtime pack paths when not using workloads fix build really fix the build --- .../BlazorWasmBuildPublishTests.cs | 36 +------------------ .../Wasm.Build.Tests/BuildTestBase.cs | 2 ++ .../NativeRebuildTestsBase.cs | 3 -- .../data/Blazor.Directory.Build.targets | 11 +++--- 4 files changed, 10 insertions(+), 42 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index d6b8acb5e1f40..b60d14e8602c2 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -20,7 +20,7 @@ public BlazorWasmBuildPublishTests(ITestOutputHelper output, SharedBuildPerTestC _enablePerTestCleanup = true; } - [Theory] + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] [InlineData("Debug")] [InlineData("Release")] public void DefaultTemplate(string config) @@ -202,13 +202,6 @@ private string CreateProjectWithNativeReference(string id) private string CreateTemplateProject(string id) { InitBlazorWasmProjectDir(id); - if (IsNotUsingWorkloads) - { - // no packs installed, so no need to update the paths for runtime pack etc - File.WriteAllText(Path.Combine(_projectDir!, "Directory.Build.props"), ""); - File.WriteAllText(Path.Combine(_projectDir!, "Directory.Build.targets"), ""); - } - new DotNetCommand(s_buildEnv, useDefaultArgs: false) .WithWorkingDirectory(_projectDir!) .ExecuteWithCapturedOutput("new blazorwasm") @@ -216,33 +209,6 @@ private string CreateTemplateProject(string id) return Path.Combine(_projectDir!, $"{id}.csproj"); } - - private string AddItemsPropertiesToProject(string projectFile, string? extraProperties=null, string? extraItems=null) - { - if (extraProperties == null && extraItems == null) - return projectFile; - - XmlDocument doc = new(); - doc.Load(projectFile); - - if (extraItems != null) - { - XmlNode node = doc.CreateNode(XmlNodeType.Element, "ItemGroup", null); - node.InnerXml = extraItems; - doc.DocumentElement!.AppendChild(node); - } - - if (extraProperties != null) - { - XmlNode node = doc.CreateNode(XmlNodeType.Element, "PropertyGroup", null); - node.InnerXml = extraProperties; - doc.DocumentElement!.AppendChild(node); - } - - doc.Save(projectFile); - - return projectFile; - } } internal enum NativeFilesType { FromRuntimePack, Relinked, AOT }; diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index 3030f8d852949..b80873ad65d85 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -695,4 +695,6 @@ public record BuildArgs(string ProjectName, string ProjectFileContents, string? ExtraBuildArgs); public record BuildProduct(string ProjectDir, string LogFile, bool Result); + internal record FileStat (bool Exists, DateTime LastWriteTimeUtc, long Length, string FullPath); + internal record BuildPaths(string ObjWasmDir, string ObjDir, string BinDir, string BundleDir); } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NativeRebuildTestsBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NativeRebuildTestsBase.cs index 0e252fb064ef5..9047fd062a82e 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NativeRebuildTestsBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/NativeRebuildTestsBase.cs @@ -181,7 +181,4 @@ protected void AssertSubstring(string substring, string full, bool contains) Assert.DoesNotContain(substring, full); } } - - internal record FileStat (bool Exists, DateTime LastWriteTimeUtc, long Length, string FullPath); - internal record BuildPaths(string ObjWasmDir, string ObjDir, string BinDir, string BundleDir); } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Directory.Build.targets b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Directory.Build.targets index f77fc96c48d05..5cef9821d8f80 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Directory.Build.targets +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Directory.Build.targets @@ -10,7 +10,8 @@ + AfterTargets="ProcessFrameworkReferences" + Condition="'$(WasmNativeWorkload)' == 'true'"> @@ -21,7 +22,8 @@ + AfterTargets="ResolveFrameworkReferences" + Condition="'$(WasmNativeWorkload)' == 'true'"> + AfterTargets="ResolveTargetingPackAssets" + Condition="'$(WasmNativeWorkload)' == 'true'"> @@ -56,7 +59,7 @@ From 2dbc8990f72d8d51d30cd27f142e6e77c26f8560 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 7 Sep 2021 17:20:40 -0400 Subject: [PATCH 12/46] [wasm] Fix building blazor projects with no workload installed - And add extra checks for verifying that --- .../scenarios/BuildWasmAppsJobsList.txt | 2 +- src/mono/wasm/BlazorOverwrite.targets | 8 ++- src/mono/wasm/build/WasmApp.targets | 13 ++-- .../BlazorWasmBuildPublishTests.cs | 44 ++++++++----- .../Wasm.Build.Tests/BlazorWasmTests.cs | 50 +++------------ .../Wasm.Build.Tests/BuildEnvironment.cs | 3 + .../Wasm.Build.Tests/BuildTestBase.cs | 63 +++++++++++++++++-- .../Wasm.Build.Tests/NativeBuildTests.cs | 7 +-- .../BlazorWasmRebuildTests.cs | 37 ----------- 9 files changed, 115 insertions(+), 112 deletions(-) delete mode 100644 src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/BlazorWasmRebuildTests.cs diff --git a/eng/testing/scenarios/BuildWasmAppsJobsList.txt b/eng/testing/scenarios/BuildWasmAppsJobsList.txt index 9f0ea66754e2e..93ca29d748f85 100644 --- a/eng/testing/scenarios/BuildWasmAppsJobsList.txt +++ b/eng/testing/scenarios/BuildWasmAppsJobsList.txt @@ -1,4 +1,4 @@ -Wasm.Build.NativeRebuild.Tests.BlazorWasmRebuildTest +Wasm.Build.NativeRebuild.Tests.BlazorWasmRebuildTests Wasm.Build.NativeRebuild.Tests.FlagsChangeRebuildTest Wasm.Build.NativeRebuild.Tests.NoopNativeRebuildTest Wasm.Build.NativeRebuild.Tests.ReferenceNewAssemblyRebuildTest diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index ced77c3303efa..1f2997af56cef 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -72,6 +72,8 @@ Copyright (c) .NET Foundation. All rights reserved. true false ComputeFilesToPublish;_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn) + <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' != 'true'">ResolveRuntimePackAssets + <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'">WasmBuildApp @@ -157,7 +159,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + @@ -211,13 +213,15 @@ Copyright (c) .NET Foundation. All rights reserved. + + - + diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index f9ae90547f2d0..3f57bc965aeb4 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -83,12 +83,13 @@ <_BeforeWasmBuildAppDependsOn /> true - true - <_WasmBuildAppAfterThisTarget Condition="'$(DisableAutoWasmBuildApp)' != 'true'">Build + + true + Build - true - <_WasmTriggerPublishAppAfterThisTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true' and '$(WasmBuildingForPublish)' != 'true'">Publish + true + Publish <_WasmNestedPublishAppPreTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish true @@ -97,7 +98,7 @@ @@ -147,7 +148,7 @@ diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index b60d14e8602c2..a482794272dc4 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -4,7 +4,6 @@ using System; using System.IO; using System.Linq; -using System.Xml; using Xunit; using Xunit.Abstractions; @@ -20,13 +19,32 @@ public BlazorWasmBuildPublishTests(ITestOutputHelper output, SharedBuildPerTestC _enablePerTestCleanup = true; } + [ConditionalTheory(typeof(BuildTestBase), nameof(IsNotUsingWorkloads))] + [InlineData("Debug")] + [InlineData("Release")] + public void DefaultTemplate_WithoutWorkload(string config) + { + string id = $"blz_no_workload_{config}"; + CreateBlazorWasmTemplateProject(id); + + // Build + BuildInternal(id, config, publish: false); + string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", "wwwroot", "_framework"); + AssertBlazorBootJson(config, isPublish: false, binFrameworkDir); + + // Publish + BuildInternal(id, config, publish: true); + binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", "publish", "wwwroot", "_framework"); + AssertBlazorBootJson(config, isPublish: true, binFrameworkDir); + } + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] [InlineData("Debug")] [InlineData("Release")] - public void DefaultTemplate(string config) + public void DefaultTemplate_NoAOT_WithWorkload(string config) { string id = $"blz_no_aot_{config}"; - CreateTemplateProject(id); + CreateBlazorWasmTemplateProject(id); BlazorBuild(id, config, NativeFilesType.FromRuntimePack); if (config == "Release") @@ -46,7 +64,7 @@ public void DefaultTemplate(string config) public void DefaultTemplate_AOT_InProjectFile(string config) { string id = $"blz_aot_prj_file_{config}"; - string projectFile = CreateTemplateProject(id); + string projectFile = CreateBlazorWasmTemplateProject(id); AddItemsPropertiesToProject(projectFile, extraProperties: "true"); // No relinking, no AOT @@ -65,7 +83,7 @@ public void DefaultTemplate_AOT_InProjectFile(string config) public void DefaultTemplate_AOT_OnlyWithPublishCommandLine_Then_PublishNoAOT(string config) { string id = $"blz_aot_pub_{config}"; - CreateTemplateProject(id); + CreateBlazorWasmTemplateProject(id); // No relinking, no AOT BlazorBuild(id, config, NativeFilesType.FromRuntimePack); @@ -101,7 +119,7 @@ public void WithNativeReference_AOTInProjectFile(string config) public void WithNativeReference_AOTOnCommandLine(string config) { string id = $"blz_nativeref_aot_{config}"; - string projectFile = CreateProjectWithNativeReference(id); + CreateProjectWithNativeReference(id); BlazorBuild(id, config, expectedFileType: NativeFilesType.Relinked); @@ -115,6 +133,7 @@ public void WithNativeReference_AOTOnCommandLine(string config) { var res = BuildInternal(id, config, publish: false, extraArgs); AssertDotNetNativeFiles(expectedFileType, config, forPublish: false); + AssertBlazorBundle(config, isPublish: false, dotnetWasmFromRuntimePack: expectedFileType == NativeFilesType.FromRuntimePack); return res; } @@ -123,6 +142,7 @@ public void WithNativeReference_AOTOnCommandLine(string config) { var res = BuildInternal(id, config, publish: true, extraArgs); AssertDotNetNativeFiles(expectedFileType, config, forPublish: true); + AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: expectedFileType == NativeFilesType.FromRuntimePack); return res; } @@ -184,7 +204,7 @@ private void AssertDotNetNativeFiles(NativeFilesType type, string config, bool f private string CreateProjectWithNativeReference(string id) { - CreateTemplateProject(id); + CreateBlazorWasmTemplateProject(id); string extraItems = @$" @@ -199,16 +219,6 @@ private string CreateProjectWithNativeReference(string id) return projectFile; } - private string CreateTemplateProject(string id) - { - InitBlazorWasmProjectDir(id); - new DotNetCommand(s_buildEnv, useDefaultArgs: false) - .WithWorkingDirectory(_projectDir!) - .ExecuteWithCapturedOutput("new blazorwasm") - .EnsureSuccessful(); - - return Path.Combine(_projectDir!, $"{id}.csproj"); - } } internal enum NativeFilesType { FromRuntimePack, Relinked, AOT }; diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs index 6d3312b5ce4f7..37320c53e0ad8 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Generic; using System.IO; using Xunit; using Xunit.Abstractions; @@ -17,36 +16,6 @@ public BlazorWasmTests(ITestOutputHelper output, SharedBuildPerTestClassFixture { } - // TODO: invariant case? - - [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] - [InlineData("Debug", false)] - [InlineData("Debug", true)] // just aot - [InlineData("Release", false)] // should re-link - [InlineData("Release", true)] - public void PublishTemplateProject(string config, bool aot) - { - string id = $"blazorwasm_{config}_aot_{aot}_{Path.GetRandomFileName()}"; - InitBlazorWasmProjectDir(id); - - new DotNetCommand(s_buildEnv, useDefaultArgs: false) - .WithWorkingDirectory(_projectDir!) - .ExecuteWithCapturedOutput("new blazorwasm") - .EnsureSuccessful(); - - string publishLogPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}.binlog"); - new DotNetCommand(s_buildEnv) - .WithWorkingDirectory(_projectDir!) - .ExecuteWithCapturedOutput("publish", $"-bl:{publishLogPath}", aot ? "-p:RunAOTCompilation=true" : "", $"-p:Configuration={config}") - .EnsureSuccessful(); - - //TODO: validate the build somehow? - // compare dotnet.wasm? - // relinking - dotnet.wasm should be smaller - // - // playwright? - } - [ConditionalTheory(typeof(BuildTestBase), nameof(IsNotUsingWorkloads))] [InlineData("Debug")] [InlineData("Release")] @@ -54,6 +23,7 @@ public void NativeRef_EmitsWarningBecauseItRequiresWorkload(string config) { CommandResult res = PublishForRequiresWorkloadTest(config, extraItems: ""); res.EnsureSuccessful(); + AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: true); Assert.Contains("but the native references won't be linked in", res.Output); } @@ -71,7 +41,7 @@ public void AOT_FailsBecauseItRequiresWorkload(string config) [ConditionalTheory(typeof(BuildTestBase), nameof(IsNotUsingWorkloads))] [InlineData("Debug")] [InlineData("Release")] - public void AOT_And_NativeRef_FailsBecauseItRequireWorkload(string config) + public void AOT_And_NativeRef_FailBecauseTheyRequireWorkload(string config) { CommandResult res = PublishForRequiresWorkloadTest(config, extraProperties: "true", @@ -84,18 +54,13 @@ public void AOT_And_NativeRef_FailsBecauseItRequireWorkload(string config) private CommandResult PublishForRequiresWorkloadTest(string config, string extraItems="", string extraProperties="") { string id = $"needs_workload_{config}_{Path.GetRandomFileName()}"; - InitBlazorWasmProjectDir(id); - - new DotNetCommand(s_buildEnv, useDefaultArgs: false) - .WithWorkingDirectory(_projectDir!) - .ExecuteWithCapturedOutput("new blazorwasm") - .EnsureSuccessful(); + CreateBlazorWasmTemplateProject(id); if (IsNotUsingWorkloads) { // no packs installed, so no need to update the paths for runtime pack etc - File.WriteAllText(Path.Combine(_projectDir!, "Directory.Build.props"), ""); - File.WriteAllText(Path.Combine(_projectDir!, "Directory.Build.targets"), ""); + File.Copy(Path.Combine(BuildEnvironment.TestDataPath, "Blazor.Local.Directory.Build.props"), Path.Combine(_projectDir!, "Directory.Build.props"), overwrite: true); + File.Copy(Path.Combine(BuildEnvironment.TestDataPath, "Blazor.Local.Directory.Build.targets"), Path.Combine(_projectDir!, "Directory.Build.targets"), overwrite: true); } AddItemsPropertiesToProject(Path.Combine(_projectDir!, $"{id}.csproj"), @@ -167,6 +132,11 @@ private void BuildNet50Project(string config, bool aot, bool expectError, string { result.EnsureSuccessful(); Assert.Contains("** UsingBrowserRuntimeWorkload: 'false'", result.Output); + + string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net5.0", "publish", "wwwroot", "_framework"); + AssertBlazorBootJson(config, isPublish: true, binFrameworkDir: binFrameworkDir); + // dotnet.wasm here would be from 5.0 nuget like: + // /Users/radical/.nuget/packages/microsoft.netcore.app.runtime.browser-wasm/5.0.9/runtimes/browser-wasm/native/dotnet.wasm } } } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildEnvironment.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildEnvironment.cs index 8e9be9ee967c4..b1de19ba1690d 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildEnvironment.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildEnvironment.cs @@ -135,5 +135,8 @@ public BuildEnvironment() protected static string s_directoryBuildPropsForLocal = File.ReadAllText(Path.Combine(TestDataPath, "Local.Directory.Build.props")); protected static string s_directoryBuildTargetsForLocal = File.ReadAllText(Path.Combine(TestDataPath, "Local.Directory.Build.targets")); + + protected static string s_directoryBuildPropsForBlazorLocal = File.ReadAllText(Path.Combine(TestDataPath, "Blazor.Local.Directory.Build.props")); + protected static string s_directoryBuildTargetsForBlazorLocal = File.ReadAllText(Path.Combine(TestDataPath, "Blazor.Local.Directory.Build.targets")); } } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index b80873ad65d85..228da489deb56 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; +using System.Text.Json.Nodes; using System.Text.RegularExpressions; using System.Xml; using Xunit; @@ -375,6 +376,17 @@ public void InitBlazorWasmProjectDir(string id) File.Copy(Path.Combine(BuildEnvironment.TestDataPath, "Blazor.Directory.Build.targets"), Path.Combine(_projectDir, "Directory.Build.targets")); } + public string CreateBlazorWasmTemplateProject(string id) + { + InitBlazorWasmProjectDir(id); + new DotNetCommand(s_buildEnv, useDefaultArgs: false) + .WithWorkingDirectory(_projectDir!) + .ExecuteWithCapturedOutput("new blazorwasm") + .EnsureSuccessful(); + + return Path.Combine(_projectDir!, $"{id}.csproj"); + } + static void AssertRuntimePackPath(string buildOutput) { var match = s_runtimePackPathRegex.Match(buildOutput); @@ -489,6 +501,41 @@ protected static void AssertFile(string file0, string file1, string? label=null, return result; } + protected void AssertBlazorBundle(string config, bool isPublish, bool dotnetWasmFromRuntimePack, string? binFrameworkDir=null) + { + binFrameworkDir ??= Path.Combine(_projectDir!, "bin", config, "net6.0", isPublish ? "publish" : "", "wwwroot", "_framework"); + + AssertBlazorBootJson(config, isPublish, binFrameworkDir: binFrameworkDir); + AssertFile(Path.Combine(s_buildEnv.RuntimeNativeDir, "dotnet.wasm"), + Path.Combine(binFrameworkDir, "dotnet.wasm"), + "Expected dotnet.wasm to be same as the runtime pack", + same: dotnetWasmFromRuntimePack); + + string? dotnetJsPath = Directory.EnumerateFiles(binFrameworkDir, "dotnet.*.js").FirstOrDefault(); + Assert.True(dotnetJsPath != null, $"Could not find blazor's dotnet*js in {binFrameworkDir}"); + + AssertFile(Path.Combine(s_buildEnv.RuntimeNativeDir, "dotnet.js"), + dotnetJsPath!, + "Expected dotnet.js to be same as the runtime pack", + same: dotnetWasmFromRuntimePack); + } + + protected void AssertBlazorBootJson(string config, bool isPublish, string? binFrameworkDir=null) + { + binFrameworkDir ??= Path.Combine(_projectDir!, "bin", config, "net6.0", isPublish ? "publish" : "", "wwwroot", "_framework"); + + string bootJson = File.ReadAllText(Path.Combine(binFrameworkDir, "blazor.boot.json")); + var bootJsonNode = JsonNode.Parse(bootJson); + var runtimeObj = bootJsonNode?["resources"]?["runtime"]?.AsObject(); + Assert.NotNull(runtimeObj); + + string msgPrefix=$"[{( isPublish ? "publish" : "build" )}]"; + Assert.True(runtimeObj!.Where(kvp => kvp.Key == "dotnet.wasm").Any(), $"{msgPrefix} Could not find dotnet.wasm entry in blazor.boot.json"); + Assert.True(runtimeObj!.Where(kvp => kvp.Key.StartsWith("dotnet.", StringComparison.OrdinalIgnoreCase) && + kvp.Key.EndsWith(".js", StringComparison.OrdinalIgnoreCase)).Any(), + $"{msgPrefix} Could not find dotnet.*js in {bootJson}"); + } + protected string GetBinDir(string config, string targetFramework=s_targetFramework, string? baseDir=null) { var dir = baseDir ?? _projectDir; @@ -618,26 +665,34 @@ void LogData(string label, string? message) } } - public static string AddItemsPropertiesToProject(string projectFile, string? extraProperties=null, string? extraItems=null) + public static string AddItemsPropertiesToProject(string projectFile, string? extraProperties=null, string? extraItems=null, string? atTheEnd=null) { - if (extraProperties == null && extraItems == null) + if (extraProperties == null && extraItems == null && atTheEnd == null) return projectFile; XmlDocument doc = new(); doc.Load(projectFile); + XmlNode root = doc.DocumentElement ?? throw new Exception(); if (extraItems != null) { XmlNode node = doc.CreateNode(XmlNodeType.Element, "ItemGroup", null); node.InnerXml = extraItems; - doc.DocumentElement!.AppendChild(node); + root.AppendChild(node); } if (extraProperties != null) { XmlNode node = doc.CreateNode(XmlNodeType.Element, "PropertyGroup", null); node.InnerXml = extraProperties; - doc.DocumentElement!.AppendChild(node); + root.AppendChild(node); + } + + if (atTheEnd != null) + { + XmlNode node = doc.CreateNode(XmlNodeType.DocumentFragment, "foo", null); + node.InnerXml = atTheEnd; + root.InsertAfter(node, root.LastChild); } doc.Save(projectFile); diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs index 315625db9483b..126efb0c48406 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs @@ -25,17 +25,14 @@ public NativeBuildTests(ITestOutputHelper output, SharedBuildPerTestClassFixture [Theory] [BuildAndRun] public void SimpleNativeBuild(BuildArgs buildArgs, RunHost host, string id) - => NativeBuild("simple_native_build", s_mainReturns42, buildArgs, host, id); - - private void NativeBuild(string projectNamePrefix, string projectContents, BuildArgs buildArgs, RunHost host, string id) { - string projectName = $"{projectNamePrefix}_{buildArgs.Config}_{buildArgs.AOT}"; + string projectName = $"simple_native_build_{buildArgs.Config}_{buildArgs.AOT}"; buildArgs = buildArgs with { ProjectName = projectName }; buildArgs = ExpandBuildArgs(buildArgs, extraProperties: "true"); BuildProject(buildArgs, - initProject: () => File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), projectContents), + initProject: () => File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), s_mainReturns42), dotnetWasmFromRuntimePack: false, id: id); diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/BlazorWasmRebuildTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/BlazorWasmRebuildTests.cs deleted file mode 100644 index 7401adfeac87e..0000000000000 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/BlazorWasmRebuildTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Linq; -using Wasm.Build.Tests; -using Xunit; -using Xunit.Abstractions; - -#nullable enable - -namespace Wasm.Build.NativeRebuild.Tests -{ - public class BlazorWasmRebuildTests : NativeRebuildTestsBase - { - public BlazorWasmRebuildTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) - : base(output, buildContext) - { - } - - [Theory] - [MemberData(nameof(NativeBuildData))] - public void NoOpRebuild(BuildArgs buildArgs, bool nativeRelink, bool invariant, RunHost host, string id) - { - buildArgs = buildArgs with { ProjectName = $"rebuild_noop_{buildArgs.Config}" }; - (buildArgs, BuildPaths paths) = FirstNativeBuild(s_mainReturns42, nativeRelink: nativeRelink, invariant: invariant, buildArgs, id); - - var pathsDict = GetFilesTable(buildArgs, paths, unchanged: true); - var originalStat = StatFiles(pathsDict.Select(kvp => kvp.Value.fullPath)); - - Rebuild(nativeRelink, invariant, buildArgs, id); - var newStat = StatFiles(pathsDict.Select(kvp => kvp.Value.fullPath)); - - CompareStat(originalStat, newStat, pathsDict.Values); - RunAndTestWasmApp(buildArgs, buildDir: _projectDir, expectedExitCode: 42, host: host, id: id); - } - } -} From 0cfd4015b419ab972ecb9828ae8b21b1c999ac2f Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 7 Sep 2021 17:21:15 -0400 Subject: [PATCH 13/46] Update wasm README.md --- src/mono/wasm/build/README.md | 57 ++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/src/mono/wasm/build/README.md b/src/mono/wasm/build/README.md index 854ea041398fa..0a00d77325a40 100644 --- a/src/mono/wasm/build/README.md +++ b/src/mono/wasm/build/README.md @@ -1,3 +1,58 @@ +# Wasm app build + +This usually consists of taking the built assemblies, and related files, and generating an app bundle. + +Wasm app build can run in two scenarios: + +1. After build, eg. when running the app in VS, or `dotnet build foo.csproj` +2. For Publish, eg, when publishing the app to a folder, or Azure + +A dotnet wasm app has some native wasm files (`dotnet.wasm`, and `dotnet.js`). How these files are obtained, or generated: + +1. Build + a. with no native libraries referenced (AOT setting is ignored here) + - files from the runtime pack are used as-is + b. with native libraries referenced + - dotnet.wasm is relinked with the native libraries +2. Publish + - dotnet.wasm is relinked with the native libraries, and updated pinvoke/icalls from the trimmed assemblies + - if `RunAOTCompilation=true`, then the relinking includes AOT'ed assemblies + +## `Build` + +Implementation: + +- Target `WasmBuildApp` +- runs after `Build` by default + - which can be disabled by `$(DisableAutoWasmBuildApp)` + - or the run-after target can be set via `$(WasmBuildAppAfterThisTarget)` + +- To run a custom target + - *before* any of the wasm build targets, use `$(WasmBuildAppDependsOn)`, and prepend your target name to that + - *after* any of the wasm build targets, use `AfterTargets="WasmBuildApp"` on that target +- Avoid depending on this target, because it is available only when the workload is installed. Use `$(WasmNativeWorkload)` to check if it is installed. + +## `Publish` + +Implementation: + +- This part runs as a nested build using a `MSBuild` task, which means that the project gets reevaluated. So, if there were any changes made to items/properties in targets before this, then they won't be visible in the nested build. +- By default `WasmTriggerPublishApp` runs after the `Publish` target, and that triggers the nested build + - The nested build runs `WasmNestedPublishApp`, which causes `Build`, and `Publish` targets to be run + - Because this causes `Build` to be run again, if you have any targets that get triggered by that, then they will be running twice. + - But the original *build* run, and this *publish* run can be differentiated using `$(WasmBuildingForPublish)` + +- `WasmTriggerPublishApp` essentially just invokes the nested publish + - This runs after `Publish` + - which can be disabled by `$(DisableAutoWasmPublishApp)` + - or the run-after target can be set via `$(WasmTriggerPublishAppAfterThisTarget)` + + - To influence the wasm build for publish, use `WasmNestedPublishApp` + - To run a custom target before it, use `$(WasmNestedPublishAppDependsOn)` + - to run a custom target *after* it, use `AfterTargets="WasmNestedPublishApp"` + + - If you want to *dependsOn* on this, then use `DependsOnTargets="WasmTriggerPublishApp"` + # `WasmApp.{props,targets}`, and `WasmApp.InTree.{props,targets}` - Any project that wants to use this, can import the props+targets, and set up the @@ -74,4 +129,4 @@ them for the new task assembly. 3. Make changes similar to the one for existing dependent tasks in - `eng/testing/linker/trimmingTests.targets`, - `src/tests/Common/wasm-test-runner/WasmTestRunner.proj` - - `src/tests/Directory.Build.targets` \ No newline at end of file + - `src/tests/Directory.Build.targets` From 81654071e38490eef5ad79ea9b8655d3682e6850 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 7 Sep 2021 18:31:22 -0400 Subject: [PATCH 14/46] Add missing files --- .../data/Blazor.Local.Directory.Build.props | 11 ++++++ .../data/Blazor.Local.Directory.Build.targets | 36 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.props create mode 100644 src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.targets diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.props b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.props new file mode 100644 index 0000000000000..909ea0382ba0e --- /dev/null +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.props @@ -0,0 +1,11 @@ + + + $(RuntimeSrcDir)\artifacts\bin\ + $([MSBuild]::NormalizeDirectory($(ArtifactsBinDir), 'microsoft.netcore.app.runtime.browser-wasm', $(RuntimeConfig))) + + + + $(WasmBuildSupportDir)\ + $([MSBuild]::NormalizeDirectory($(BuildBaseDir), 'microsoft.netcore.app.runtime.browser-wasm')) + + diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.targets b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.targets new file mode 100644 index 0000000000000..639a8413dc3f6 --- /dev/null +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.targets @@ -0,0 +1,36 @@ + + + <_MicrosoftNetCoreAppRefDir>$(AppRefDir)\ + + + + + + + + + + + + + + + + + From b4995869ebd2b7d73be5d2adb09832af22d0745f Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 7 Sep 2021 19:25:39 -0400 Subject: [PATCH 15/46] WasmApp.targets: remove hack for blazor, which is not needed now --- src/mono/wasm/build/WasmApp.targets | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 3f57bc965aeb4..a3d87da73cfaa 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -83,12 +83,8 @@ <_BeforeWasmBuildAppDependsOn /> true - - true Build - - true Publish <_WasmNestedPublishAppPreTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish From 0ec11880f605495e8ac1817f0bec2562c82a1719 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 7 Sep 2021 20:32:57 -0400 Subject: [PATCH 16/46] add comments for the new properties --- src/mono/wasm/build/WasmApp.targets | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index a3d87da73cfaa..5fc1c60275509 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -52,6 +52,15 @@ - $(EmccExtraCFlags) - Extra emcc flags for compiling native files - $(EmccTotalMemory) - Total memory specified with `emcc`. Default value: 536870912 + - $(WasmBuildAppAfterThisTarget) - This target is used as `AfterTargets` for `WasmBuildApp. this + is what triggers the wasm app building. Defaults to `Build`. + - $(WasmTriggerPublishAppAfterThisTarget) - This target is used as `AfterTargets` for `WasmTriggerPublishApp. + Defaults to `Publish`. + + - $(EnableDefaultWasmAssembliesToBundle) - Get list of assemblies to bundle automatically. Defaults to true. + - $(WasmBuildOnlyAfterPublish) - Causes relinking to be done only for Publish. Defaults to false. + - $(RunAOTCompilationAfterBuild) - Run AOT compilation even after Build. By default, it is run only for publish. + Defaults to false. Public items: - @(WasmExtraFilesToDeploy) - Files to copy to $(WasmAppDir). From 567144c1aae4e49bc806fddb5bfc02bd3f53fb54 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 7 Sep 2021 22:04:12 -0400 Subject: [PATCH 17/46] blazor-sdk: cleanup assemblies list before adding to it --- src/mono/wasm/BlazorOverwrite.targets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index 1f2997af56cef..faf06623d75bc 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -217,6 +217,7 @@ Copyright (c) .NET Foundation. All rights reserved. + @@ -667,6 +668,7 @@ Copyright (c) .NET Foundation. All rights reserved. + From c906da863273368b3b69fdb98330b367f5f68d4f Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 8 Sep 2021 16:43:23 -0400 Subject: [PATCH 18/46] Fix "Clean" for blazorwasm projects, for *Build* Partially fixes https://github.com/dotnet/runtime/issues/58826 --- .../scenarios/BuildWasmAppsJobsList.txt | 2 +- src/mono/wasm/build/WasmApp.Native.targets | 37 +++++- .../WasmAppBuilder/IcallTableGenerator.cs | 4 + .../WasmAppBuilder/PInvokeTableGenerator.cs | 4 + .../BlazorWasmBuildPublishTests.cs | 75 +----------- .../Wasm.Build.Tests/BuildTestBase.cs | 73 ++++++++++++ .../Wasm.Build.Tests/CleanTests.cs | 110 ++++++++++++++++++ 7 files changed, 224 insertions(+), 81 deletions(-) create mode 100644 src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs diff --git a/eng/testing/scenarios/BuildWasmAppsJobsList.txt b/eng/testing/scenarios/BuildWasmAppsJobsList.txt index 93ca29d748f85..c4c5a1875c3bf 100644 --- a/eng/testing/scenarios/BuildWasmAppsJobsList.txt +++ b/eng/testing/scenarios/BuildWasmAppsJobsList.txt @@ -1,4 +1,3 @@ -Wasm.Build.NativeRebuild.Tests.BlazorWasmRebuildTests Wasm.Build.NativeRebuild.Tests.FlagsChangeRebuildTest Wasm.Build.NativeRebuild.Tests.NoopNativeRebuildTest Wasm.Build.NativeRebuild.Tests.ReferenceNewAssemblyRebuildTest @@ -6,6 +5,7 @@ Wasm.Build.NativeRebuild.Tests.SimpleSourceChangeRebuildTest Wasm.Build.Tests.BlazorWasmBuildPublishTests Wasm.Build.Tests.BlazorWasmTests Wasm.Build.Tests.BuildPublishTests +Wasm.Build.Tests.CleanTests Wasm.Build.Tests.InvariantGlobalizationTests Wasm.Build.Tests.LocalEMSDKTests Wasm.Build.Tests.MainWithArgsTests diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets index 4a9fbbbab9ff5..94a47deac17e3 100644 --- a/src/mono/wasm/build/WasmApp.Native.targets +++ b/src/mono/wasm/build/WasmApp.Native.targets @@ -236,7 +236,9 @@ + OutputPath="$(_WasmPInvokeTablePath)"> + + @@ -244,10 +246,16 @@ Text="Could not find AOT cross compiler at %24(_MonoAotCrossCompilerPath)=$(_MonoAotCrossCompilerPath)" /> + + + + + OutputPath="$(_WasmICallTablePath)"> + + @@ -263,6 +271,9 @@ + + + @@ -276,7 +287,9 @@ SourceFiles="@(_WasmSourceFileToCompile)" Arguments='"@$(_EmccDefaultFlagsRsp)" "@$(_EmccCompileRsp)"' EnvironmentVariables="@(EmscriptenEnvVars)" - OutputMessageImportance="$(_EmccCompileOutputMessageImportance)" /> + OutputMessageImportance="$(_EmccCompileOutputMessageImportance)"> + + + OutputMessageImportance="$(_EmccCompileOutputMessageImportance)"> + + @@ -303,6 +318,9 @@ <_BitcodeLDFlags Include="$(EmccExtraBitcodeLDFlags)" /> + + + @@ -312,8 +330,8 @@ <_WasmNativeFileForLinking Include="%(_WasmSourceFileToCompile.ObjectFile)" /> <_WasmNativeFileForLinking - Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)\*.a" - Exclude="@(_MonoRuntimeComponentDontLink->'$(MicrosoftNetCoreAppRuntimePackRidNativeDir)\%(Identity)')" /> + Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)*.a" + Exclude="@(_MonoRuntimeComponentDontLink->'$(MicrosoftNetCoreAppRuntimePackRidNativeDir)%(Identity)')" /> <_WasmExtraJSFile Include="@(Content)" Condition="'%(Content.Extension)' == '.js'" /> @@ -336,6 +354,9 @@ + + + + + + + diff --git a/src/tasks/WasmAppBuilder/IcallTableGenerator.cs b/src/tasks/WasmAppBuilder/IcallTableGenerator.cs index 13c75c39bc64c..cc4d8af1ac7fa 100644 --- a/src/tasks/WasmAppBuilder/IcallTableGenerator.cs +++ b/src/tasks/WasmAppBuilder/IcallTableGenerator.cs @@ -23,6 +23,9 @@ public class IcallTableGenerator : Task [Required, NotNull] public string? OutputPath { get; set; } + [Output] + public string? FileWrites { get; private set; } = ""; + private List _icalls = new List (); private Dictionary _runtimeIcalls = new Dictionary (); @@ -58,6 +61,7 @@ public void GenIcallTable(string runtimeIcallTableFile, string[] assemblies) Log.LogMessage(MessageImportance.Low, $"Generating icall table to '{OutputPath}'."); else Log.LogMessage(MessageImportance.Low, $"Icall table in {OutputPath} is unchanged."); + FileWrites = OutputPath; File.Delete(tmpFileName); } diff --git a/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs b/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs index bedd507f5115f..825de67d6e270 100644 --- a/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs +++ b/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs @@ -24,6 +24,9 @@ public class PInvokeTableGenerator : Task [Required, NotNull] public string? OutputPath { get; set; } + [Output] + public string FileWrites { get; private set; } = string.Empty; + private static char[] s_charsToReplace = new[] { '.', '-', }; public override bool Execute() @@ -81,6 +84,7 @@ public void GenPInvokeTable(string[] pinvokeModules, string[] assemblies) Log.LogMessage(MessageImportance.Low, $"Generating pinvoke table to '{OutputPath}'."); else Log.LogMessage(MessageImportance.Low, $"PInvoke table in {OutputPath} is unchanged."); + FileWrites = OutputPath; File.Delete(tmpFileName); } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index a482794272dc4..52df1e1222e4d 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -129,79 +129,6 @@ public void WithNativeReference_AOTOnCommandLine(string config) BlazorPublish(id, config, expectedFileType: NativeFilesType.Relinked); } - private (CommandResult, string) BlazorBuild(string id, string config, NativeFilesType expectedFileType, params string[] extraArgs) - { - var res = BuildInternal(id, config, publish: false, extraArgs); - AssertDotNetNativeFiles(expectedFileType, config, forPublish: false); - AssertBlazorBundle(config, isPublish: false, dotnetWasmFromRuntimePack: expectedFileType == NativeFilesType.FromRuntimePack); - - return res; - } - - private (CommandResult, string) BlazorPublish(string id, string config, NativeFilesType expectedFileType, params string[] extraArgs) - { - var res = BuildInternal(id, config, publish: true, extraArgs); - AssertDotNetNativeFiles(expectedFileType, config, forPublish: true); - AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: expectedFileType == NativeFilesType.FromRuntimePack); - return res; - } - - private (CommandResult, string) BuildInternal(string id, string config, bool publish=false, params string[] extraArgs) - { - string label = publish ? "publish" : "build"; - Console.WriteLine($"{Environment.NewLine}** {label} **{Environment.NewLine}"); - - string logPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-{label}.binlog"); - string[] combinedArgs = new[] - { - label, // same as the command name - $"-bl:{logPath}", - $"-p:Configuration={config}", - "-p:BlazorEnableCompression=false", - "-p:_WasmDevel=true" - }.Concat(extraArgs).ToArray(); - - CommandResult res = new DotNetCommand(s_buildEnv) - .WithWorkingDirectory(_projectDir!) - .ExecuteWithCapturedOutput(combinedArgs) - .EnsureSuccessful(); - - return (res, logPath); - } - - private void AssertDotNetNativeFiles(NativeFilesType type, string config, bool forPublish) - { - string label = forPublish ? "publish" : "build"; - string objBuildDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", forPublish ? "for-publish" : "relink"); - string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", forPublish ? "publish" : "", "wwwroot", "_framework"); - - string srcDir = type switch - { - NativeFilesType.FromRuntimePack => s_buildEnv.RuntimeNativeDir, - NativeFilesType.Relinked => objBuildDir, - NativeFilesType.AOT => objBuildDir, - _ => throw new ArgumentOutOfRangeException(nameof(type)) - }; - - AssertSameFile(Path.Combine(srcDir, "dotnet.wasm"), Path.Combine(binFrameworkDir, "dotnet.wasm"), label); - - // find dotnet*js - string? dotnetJsPath = Directory.EnumerateFiles(binFrameworkDir) - .Where(p => Path.GetFileName(p).StartsWith("dotnet.", StringComparison.OrdinalIgnoreCase) && - Path.GetFileName(p).EndsWith(".js", StringComparison.OrdinalIgnoreCase)) - .SingleOrDefault(); - - Assert.True(!string.IsNullOrEmpty(dotnetJsPath), $"[{label}] Expected to find dotnet*js in {binFrameworkDir}"); - AssertSameFile(Path.Combine(srcDir, "dotnet.js"), dotnetJsPath!, label); - - if (type != NativeFilesType.FromRuntimePack) - { - // check that the files are *not* from runtime pack - AssertNotSameFile(Path.Combine(s_buildEnv.RuntimeNativeDir, "dotnet.wasm"), Path.Combine(binFrameworkDir, "dotnet.wasm"), label); - AssertNotSameFile(Path.Combine(s_buildEnv.RuntimeNativeDir, "dotnet.js"), dotnetJsPath!, label); - } - } - private string CreateProjectWithNativeReference(string id) { CreateBlazorWasmTemplateProject(id); @@ -221,5 +148,5 @@ private string CreateProjectWithNativeReference(string id) } - internal enum NativeFilesType { FromRuntimePack, Relinked, AOT }; + public enum NativeFilesType { FromRuntimePack, Relinked, AOT }; } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index 228da489deb56..e1e848acaef37 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -387,6 +387,79 @@ public string CreateBlazorWasmTemplateProject(string id) return Path.Combine(_projectDir!, $"{id}.csproj"); } + protected (CommandResult, string) BlazorBuild(string id, string config, NativeFilesType expectedFileType, params string[] extraArgs) + { + var res = BuildInternal(id, config, publish: false, extraArgs); + AssertDotNetNativeFiles(expectedFileType, config, forPublish: false); + AssertBlazorBundle(config, isPublish: false, dotnetWasmFromRuntimePack: expectedFileType == NativeFilesType.FromRuntimePack); + + return res; + } + + protected (CommandResult, string) BlazorPublish(string id, string config, NativeFilesType expectedFileType, params string[] extraArgs) + { + var res = BuildInternal(id, config, publish: true, extraArgs); + AssertDotNetNativeFiles(expectedFileType, config, forPublish: true); + AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: expectedFileType == NativeFilesType.FromRuntimePack); + return res; + } + + protected (CommandResult, string) BuildInternal(string id, string config, bool publish=false, params string[] extraArgs) + { + string label = publish ? "publish" : "build"; + Console.WriteLine($"{Environment.NewLine}** {label} **{Environment.NewLine}"); + + string logPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-{label}.binlog"); + string[] combinedArgs = new[] + { + label, // same as the command name + $"-bl:{logPath}", + $"-p:Configuration={config}", + "-p:BlazorEnableCompression=false", + "-p:_WasmDevel=true" + }.Concat(extraArgs).ToArray(); + + CommandResult res = new DotNetCommand(s_buildEnv) + .WithWorkingDirectory(_projectDir!) + .ExecuteWithCapturedOutput(combinedArgs) + .EnsureSuccessful(); + + return (res, logPath); + } + + protected void AssertDotNetNativeFiles(NativeFilesType type, string config, bool forPublish) + { + string label = forPublish ? "publish" : "build"; + string objBuildDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", forPublish ? "for-publish" : "relink"); + string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", forPublish ? "publish" : "", "wwwroot", "_framework"); + + string srcDir = type switch + { + NativeFilesType.FromRuntimePack => s_buildEnv.RuntimeNativeDir, + NativeFilesType.Relinked => objBuildDir, + NativeFilesType.AOT => objBuildDir, + _ => throw new ArgumentOutOfRangeException(nameof(type)) + }; + + AssertSameFile(Path.Combine(srcDir, "dotnet.wasm"), Path.Combine(binFrameworkDir, "dotnet.wasm"), label); + + // find dotnet*js + string? dotnetJsPath = Directory.EnumerateFiles(binFrameworkDir) + .Where(p => Path.GetFileName(p).StartsWith("dotnet.", StringComparison.OrdinalIgnoreCase) && + Path.GetFileName(p).EndsWith(".js", StringComparison.OrdinalIgnoreCase)) + .SingleOrDefault(); + + Assert.True(!string.IsNullOrEmpty(dotnetJsPath), $"[{label}] Expected to find dotnet*js in {binFrameworkDir}"); + AssertSameFile(Path.Combine(srcDir, "dotnet.js"), dotnetJsPath!, label); + + if (type != NativeFilesType.FromRuntimePack) + { + // check that the files are *not* from runtime pack + AssertNotSameFile(Path.Combine(s_buildEnv.RuntimeNativeDir, "dotnet.wasm"), Path.Combine(binFrameworkDir, "dotnet.wasm"), label); + AssertNotSameFile(Path.Combine(s_buildEnv.RuntimeNativeDir, "dotnet.js"), dotnetJsPath!, label); + } + } + static void AssertRuntimePackPath(string buildOutput) { var match = s_runtimePackPathRegex.Match(buildOutput); diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs new file mode 100644 index 0000000000000..12eace67c2284 --- /dev/null +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs @@ -0,0 +1,110 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.IO; +using System.Linq; +using Wasm.Build.NativeRebuild.Tests; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +#nullable enable + +namespace Wasm.Build.Tests; + +public class CleanTests : NativeRebuildTestsBase +{ + public CleanTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) + : base(output, buildContext) + { + } + + [Theory] + [InlineData("Debug")] + [InlineData("Release")] + public void Blazor_BuildThenClean_NativeRelinking(string config) + { + string id = Path.GetRandomFileName(); + + InitBlazorWasmProjectDir(id); + string projectFile = CreateBlazorWasmTemplateProject(id); + + string extraProperties = @"<_WasmDevel>true + true"; + + AddItemsPropertiesToProject(projectFile, extraProperties: extraProperties); + BlazorBuild(id, config, NativeFilesType.Relinked); + + string relinkDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", "relink"); + Assert.True(Directory.Exists(relinkDir), $"Could not find expected relink dir: {relinkDir}"); + + string logPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-clean.binlog"); + new DotNetCommand(s_buildEnv) + .WithWorkingDirectory(_projectDir!) + .ExecuteWithCapturedOutput("build", "-t:Clean", $"-p:Configuration={config}", $"-bl:{logPath}") + .EnsureSuccessful(); + + AssertEmptyOrNonExistantDirectory(relinkDir); + } + + [Theory] + [InlineData("Debug")] + [InlineData("Release")] + public void Blazor_BuildNoNative_ThenBuildNative_ThenClean(string config) + => Blazor_BuildNativeNonNative_ThenCleanTest(config, firstBuildNative: false); + + [Theory] + [InlineData("Debug")] + [InlineData("Release")] + public void Blazor_BuildNative_ThenBuildNonNative_ThenClean(string config) + => Blazor_BuildNativeNonNative_ThenCleanTest(config, firstBuildNative: true); + + private void Blazor_BuildNativeNonNative_ThenCleanTest(string config, bool firstBuildNative) + { + string id = Path.GetRandomFileName(); + + InitBlazorWasmProjectDir(id); + string projectFile = CreateBlazorWasmTemplateProject(id); + + string extraProperties = @"<_WasmDevel>true"; + + AddItemsPropertiesToProject(projectFile, extraProperties: extraProperties); + + bool relink = firstBuildNative; + BuildInternal(id, config, publish: false, + extraArgs: relink ? "-p:WasmBuildNative=true" : string.Empty); + + string relinkDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", "relink"); + if (relink) + Assert.True(Directory.Exists(relinkDir), $"Could not find expected relink dir: {relinkDir}"); + + relink = !firstBuildNative; + BuildInternal(id, config, publish: false, + extraArgs: relink ? "-p:WasmBuildNative=true" : string.Empty); + + if (relink) + Assert.True(Directory.Exists(relinkDir), $"Could not find expected relink dir: {relinkDir}"); + + string logPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-clean.binlog"); + new DotNetCommand(s_buildEnv) + .WithWorkingDirectory(_projectDir!) + .ExecuteWithCapturedOutput("build", "-t:Clean", $"-p:Configuration={config}", $"-bl:{logPath}") + .EnsureSuccessful(); + + AssertEmptyOrNonExistantDirectory(relinkDir); + } + private void AssertEmptyOrNonExistantDirectory(string dirPath) + { + Console.WriteLine($"dirPath: {dirPath}"); + if (!Directory.Exists(dirPath)) + return; + + var files = Directory.GetFileSystemEntries(dirPath); + if (files.Length == 0) + return; + + string found = string.Join(',', files.Select(p => Path.GetFileName(p))); + throw new XunitException($"Expected dir {dirPath} to be empty, but found: {found}"); + } +} From 1ecf92d2eb1d65f4dec1d186a3cd9aee3d61ccf3 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 9 Sep 2021 16:42:14 -0400 Subject: [PATCH 19/46] [wasm] Rename tmp folder 'relink' to 'for-build' Renames the temporary folder used for native files built after *Build* target, from `relink` to `for-build`, to be consistent with publish. --- src/mono/wasm/build/WasmApp.targets | 2 +- src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs | 4 ++-- src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 5fc1c60275509..3cd642e94d0d0 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -171,7 +171,7 @@ <_WasmRuntimePackIncludeDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include')) <_WasmRuntimePackSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src')) - <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForPublish)' == ''">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'relink')) + <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForPublish)' == ''">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'for-build')) <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForPublish)' != ''">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'for-publish')) <_DriverGenCPath>$(_WasmIntermediateOutputPath)driver-gen.c diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index e1e848acaef37..b2f9e939beeae 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -430,7 +430,7 @@ public string CreateBlazorWasmTemplateProject(string id) protected void AssertDotNetNativeFiles(NativeFilesType type, string config, bool forPublish) { string label = forPublish ? "publish" : "build"; - string objBuildDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", forPublish ? "for-publish" : "relink"); + string objBuildDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", forPublish ? "for-publish" : "for-build"); string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", forPublish ? "publish" : "", "wwwroot", "_framework"); string srcDir = type switch @@ -789,7 +789,7 @@ internal BuildPaths GetBuildPaths(BuildArgs buildArgs, bool forPublish=true) { string objDir = GetObjDir(buildArgs.Config); string bundleDir = Path.Combine(GetBinDir(baseDir: _projectDir, config: buildArgs.Config), "AppBundle"); - string wasmDir = Path.Combine(objDir, "wasm", forPublish ? "for-publish" : "relink"); + string wasmDir = Path.Combine(objDir, "wasm", forPublish ? "for-publish" : "for-build"); return new BuildPaths(wasmDir, objDir, GetBinDir(buildArgs.Config), bundleDir); } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs index 12eace67c2284..d6ebebd78c2eb 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs @@ -36,7 +36,7 @@ public void Blazor_BuildThenClean_NativeRelinking(string config) AddItemsPropertiesToProject(projectFile, extraProperties: extraProperties); BlazorBuild(id, config, NativeFilesType.Relinked); - string relinkDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", "relink"); + string relinkDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", "for-build"); Assert.True(Directory.Exists(relinkDir), $"Could not find expected relink dir: {relinkDir}"); string logPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-clean.binlog"); @@ -75,7 +75,7 @@ private void Blazor_BuildNativeNonNative_ThenCleanTest(string config, bool first BuildInternal(id, config, publish: false, extraArgs: relink ? "-p:WasmBuildNative=true" : string.Empty); - string relinkDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", "relink"); + string relinkDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", "for-build"); if (relink) Assert.True(Directory.Exists(relinkDir), $"Could not find expected relink dir: {relinkDir}"); From 40d671324d90ada111cc02160e1f45e6022e5eab Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 9 Sep 2021 20:34:10 -0400 Subject: [PATCH 20/46] [wasm] Fix support for AOT with trimming disabled When publishing with AOT (`RunAOTCompilation=true`), the assemblies get trimmed by the linker, and copied to a single `linked/` folder. Then `MonoAOTCompiler` runs `mono-aot-cross` on those assemblies. Since, all the assemblies have their dependencies in the same folder too, `mono-aot-cross` can resolve them from there. But when trimming is disabled (`PublishTrimmed=false`), `MonoAOTCompiler` gets paths to assemblies from different folders. For example, some might be from `obj`, nugets etc. Which means that `mono-aot-cross` might not always be able to find dependencies for the assemblies being AOTed. To fix this, if all the input assemblies are not in the same directory, then we copy them to a temporary one, and then run `mono-aot-cross` on them. Fixes #53804 --- eng/testing/tests.mobile.targets | 2 + .../sample/Android/AndroidSampleApp.csproj | 1 + src/mono/wasm/BlazorOverwrite.targets | 10 +- src/mono/wasm/build/WasmApp.Native.targets | 16 +- src/tasks/AotCompilerTask/MonoAOTCompiler.cs | 138 ++++++++++++------ src/tasks/Common/Utils.cs | 2 +- src/tasks/WasmAppBuilder/EmccCompile.cs | 2 +- .../Wasm.Build.Tests/NativeBuildTests.cs | 56 +++++++ 8 files changed, 167 insertions(+), 60 deletions(-) diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index eab1790ec927f..ce6bfe2302ce6 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -105,6 +105,7 @@ OutputType="AsmOnly" Assemblies="@(AotInputAssemblies)" AotModulesTablePath="$(BundleDir)\modules.c" + IntermediateOutputPath="$(IntermediateOutputPath)" UseLLVM="$(MonoEnableLLVM)" LLVMPath="$(MonoAotCrossDir)"> @@ -190,6 +191,7 @@ Assemblies="@(AotInputAssemblies)" AotModulesTablePath="$(BundleDir)\modules.m" AotModulesTableLanguage="ObjC" + IntermediateOutputPath="$(IntermediateOutputPath)" UseLLVM="$(MonoEnableLLVM)" LLVMPath="$(MonoAotCrossDir)"> diff --git a/src/mono/sample/Android/AndroidSampleApp.csproj b/src/mono/sample/Android/AndroidSampleApp.csproj index 1abf7659bd099..a5129bdfe82c6 100644 --- a/src/mono/sample/Android/AndroidSampleApp.csproj +++ b/src/mono/sample/Android/AndroidSampleApp.csproj @@ -72,6 +72,7 @@ AotModulesTablePath="$(_AotModulesTablePath)" ToolPrefix="$(_AotToolPrefix)" LibraryFormat="$(_AotLibraryFormat)" + IntermediateOutputPath="$(IntermediateOutputPath)" UseLLVM="$(UseLLVM)" LLVMPath="$(MonoAotCrossDir)"> diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index faf06623d75bc..c4bcfa156ec44 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -122,6 +122,7 @@ Copyright (c) .NET Foundation. All rights reserved. + <_DotNetJsItem Remove="@(_DotNetJsItem)" /> <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'"> _framework/$(_BlazorDotnetJsFileName) native @@ -129,6 +130,12 @@ Copyright (c) .NET Foundation. All rights reserved. + + <_DotnetJsStaticWebAssetCandidate Remove="@(_DotnetJsStaticWebAssetCandidate)" /> + <_DotnetJsCopyCandidates Remove="@(_DotnetJsCopyCandidates)" /> + + + - + + diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets index 94a47deac17e3..8ddcce7af04ee 100644 --- a/src/mono/wasm/build/WasmApp.Native.targets +++ b/src/mono/wasm/build/WasmApp.Native.targets @@ -458,7 +458,7 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ - <_AotInputAssemblies Include="@(_WasmAssembliesInternal)" Exclude="@(_AOT_AssembliesForceToInterpret)"> + <_AotInputAssemblies Include="@(_WasmAssembliesInternal)"> @(MonoAOTCompilerDefaultAotArguments, ';') @(MonoAOTCompilerDefaultProcessArguments, ';') @@ -475,9 +475,6 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ <_AOTCompilerCacheFile>$(_WasmIntermediateOutputPath)aot_compiler_cache.json - - @@ -517,7 +514,8 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ DedupAssembly="$(_WasmDedupAssembly)" CacheFilePath="$(_AOTCompilerCacheFile)" LLVMDebug="dwarfdebug" - LLVMPath="$(EmscriptenUpstreamBinPath)" > + LLVMPath="$(EmscriptenUpstreamBinPath)" + IntermediateOutputPath="$(_WasmIntermediateOutputPath)"> @@ -526,9 +524,6 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ <_BitcodeFile Include="%(_WasmAssembliesInternal.LlvmBitcodeFile)" /> <_BitcodeFile ObjectFile="$(_WasmIntermediateOutputPath)%(FileName).o" /> - - - <_WasmAssembliesInternal Include="@(_AOT_AssembliesForceToInterpret)" /> @@ -539,11 +534,10 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ - <_AOTedAssemblies Include="@(_WasmAssembliesInternal)" Exclude="@(_AOT_AssembliesForceToInterpret)" /> + <_AOTedAssemblies Include="@(_WasmAssembliesInternal)" /> <_WasmStrippedAssemblies Include="@(_AOTedAssemblies)" OriginalPath="%(_WasmAssembliesInternal.Identity)" /> - <_WasmInterpOnlyAssembly Include="@(_AOT_AssembliesForceToInterpret)" /> @@ -553,7 +547,7 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" /> - <_WasmAssembliesInternal Include="@(_WasmStrippedAssemblies);@(_WasmInterpOnlyAssembly)" /> + <_WasmAssembliesInternal Include="@(_WasmStrippedAssemblies)" /> diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index 8ec425fac8b66..58e1213bdcb24 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -191,11 +191,15 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task /// public string? CacheFilePath { get; set; } + [Required] + public string IntermediateOutputPath { get; set; } = string.Empty; + [Output] public string[]? FileWrites { get; private set; } private List _fileWrites = new(); + private IList? _assembliesToCompile; private ConcurrentDictionary compiledAssemblies = new(); private MonoAotMode parsedAotMode; @@ -207,7 +211,8 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task private int _numCompiled; private int _totalNumAssemblies; - public override bool Execute() + + private bool ProcessAndValidateArguments() { if (!File.Exists(CompilerBinaryPath)) { @@ -230,6 +235,9 @@ public override bool Execute() return false; } + if (!Directory.Exists(IntermediateOutputPath)) + Directory.CreateDirectory(IntermediateOutputPath); + if (AotProfilePath != null) { foreach (var path in AotProfilePath) @@ -246,7 +254,7 @@ public override bool Execute() { if (string.IsNullOrEmpty(LLVMPath)) // prevent using some random llc/opt from PATH (installed with clang) - throw new ArgumentException($"'{nameof(LLVMPath)}' is required when '{nameof(UseLLVM)}' is true.", nameof(LLVMPath)); + throw new LogAsErrorException($"'{nameof(LLVMPath)}' is required when '{nameof(UseLLVM)}' is true."); if (!Directory.Exists(LLVMPath)) { @@ -270,7 +278,7 @@ public override bool Execute() Log.LogWarning($"'{nameof(OutputType)}=Normal' is deprecated, use 'ObjectFile' instead."); parsedOutputType = MonoAotOutputType.ObjectFile; break; default: - throw new ArgumentException($"'{nameof(OutputType)}' must be one of: '{nameof(MonoAotOutputType.ObjectFile)}', '{nameof(MonoAotOutputType.AsmOnly)}', '{nameof(MonoAotOutputType.Library)}'. Received: '{OutputType}'.", nameof(OutputType)); + throw new LogAsErrorException($"'{nameof(OutputType)}' must be one of: '{nameof(MonoAotOutputType.ObjectFile)}', '{nameof(MonoAotOutputType.AsmOnly)}', '{nameof(MonoAotOutputType.Library)}'. Received: '{OutputType}'."); } switch (LibraryFormat) @@ -280,13 +288,13 @@ public override bool Execute() case "So": parsedLibraryFormat = MonoAotLibraryFormat.So; break; default: if (parsedOutputType == MonoAotOutputType.Library) - throw new ArgumentException($"'{nameof(LibraryFormat)}' must be one of: '{nameof(MonoAotLibraryFormat.Dll)}', '{nameof(MonoAotLibraryFormat.Dylib)}', '{nameof(MonoAotLibraryFormat.So)}'. Received: '{LibraryFormat}'.", nameof(LibraryFormat)); + throw new LogAsErrorException($"'{nameof(LibraryFormat)}' must be one of: '{nameof(MonoAotLibraryFormat.Dll)}', '{nameof(MonoAotLibraryFormat.Dylib)}', '{nameof(MonoAotLibraryFormat.So)}'. Received: '{LibraryFormat}'."); break; } if (parsedAotMode == MonoAotMode.LLVMOnly && !UseLLVM) { - throw new ArgumentException($"'{nameof(UseLLVM)}' must be true when '{nameof(Mode)}' is {nameof(MonoAotMode.LLVMOnly)}.", nameof(UseLLVM)); + throw new LogAsErrorException($"'{nameof(UseLLVM)}' must be true when '{nameof(Mode)}' is {nameof(MonoAotMode.LLVMOnly)}."); } switch (AotModulesTableLanguage) @@ -294,33 +302,56 @@ public override bool Execute() case "C": parsedAotModulesTableLanguage = MonoAotModulesTableLanguage.C; break; case "ObjC": parsedAotModulesTableLanguage = MonoAotModulesTableLanguage.ObjC; break; default: - throw new ArgumentException($"'{nameof(AotModulesTableLanguage)}' must be one of: '{nameof(MonoAotModulesTableLanguage.C)}', '{nameof(MonoAotModulesTableLanguage.ObjC)}'. Received: '{AotModulesTableLanguage}'.", nameof(AotModulesTableLanguage)); + throw new LogAsErrorException($"'{nameof(AotModulesTableLanguage)}' must be one of: '{nameof(MonoAotModulesTableLanguage.C)}', '{nameof(MonoAotModulesTableLanguage.ObjC)}'. Received: '{AotModulesTableLanguage}'."); } if (!string.IsNullOrEmpty(AotModulesTablePath)) { // AOT modules for static linking, needs the aot modules table UseStaticLinking = true; - - if (!GenerateAotModulesTable(Assemblies, Profilers, AotModulesTablePath)) - return false; } if (UseDirectIcalls && !UseStaticLinking) { - throw new ArgumentException($"'{nameof(UseDirectIcalls)}' can only be used with '{nameof(UseStaticLinking)}=true'.", nameof(UseDirectIcalls)); + throw new LogAsErrorException($"'{nameof(UseDirectIcalls)}' can only be used with '{nameof(UseStaticLinking)}=true'."); } if (UseDirectPInvoke && !UseStaticLinking) { - throw new ArgumentException($"'{nameof(UseDirectPInvoke)}' can only be used with '{nameof(UseStaticLinking)}=true'.", nameof(UseDirectPInvoke)); + throw new LogAsErrorException($"'{nameof(UseDirectPInvoke)}' can only be used with '{nameof(UseStaticLinking)}=true'."); } if (UseStaticLinking && (parsedOutputType == MonoAotOutputType.Library)) { - throw new ArgumentException($"'{nameof(OutputType)}=Library' can not be used with '{nameof(UseStaticLinking)}=true'.", nameof(OutputType)); + throw new LogAsErrorException($"'{nameof(OutputType)}=Library' can not be used with '{nameof(UseStaticLinking)}=true'."); } + return true; + } + + public override bool Execute() + { + try + { + return ExecuteInternal(); + } + catch (LogAsErrorException laee) + { + Log.LogError(laee.Message); + return false; + } + } + + private bool ExecuteInternal() + { + if (!ProcessAndValidateArguments()) + return false; + + _assembliesToCompile = EnsureAndGetAssembliesInTheSameDir(Assemblies); + + if (!string.IsNullOrEmpty(AotModulesTablePath) && !GenerateAotModulesTable(_assembliesToCompile, Profilers, AotModulesTablePath)) + return false; + string? monoPaths = null; if (AdditionalAssemblySearchPaths != null) monoPaths = string.Join(Path.PathSeparator.ToString(), AdditionalAssemblySearchPaths); @@ -329,14 +360,14 @@ public override bool Execute() //FIXME: check the nothing changed at all case - _totalNumAssemblies = Assemblies.Length; - int allowedParallelism = Math.Min(Assemblies.Length, Environment.ProcessorCount); + _totalNumAssemblies = _assembliesToCompile.Count; + int allowedParallelism = Math.Min(_assembliesToCompile.Count, Environment.ProcessorCount); if (BuildEngine is IBuildEngine9 be9) allowedParallelism = be9.RequestCores(allowedParallelism); if (DisableParallelAot || allowedParallelism == 1) { - foreach (var assemblyItem in Assemblies) + foreach (var assemblyItem in _assembliesToCompile) { if (!PrecompileLibrarySerial(assemblyItem, monoPaths)) return !Log.HasLoggedErrors; @@ -345,15 +376,12 @@ public override bool Execute() else { ParallelLoopResult result = Parallel.ForEach( - Assemblies, + _assembliesToCompile, new ParallelOptions { MaxDegreeOfParallelism = allowedParallelism }, (assemblyItem, state) => PrecompileLibraryParallel(assemblyItem, monoPaths, state)); if (!result.IsCompleted) { - if (!Log.HasLoggedErrors) - Log.LogError("Unknown failure occured while compiling"); - return false; } } @@ -365,12 +393,48 @@ public override bool Execute() if (_cache.Save(CacheFilePath!)) _fileWrites.Add(CacheFilePath!); - CompiledAssemblies = ConvertAssembliesDictToOrderedList(compiledAssemblies, Assemblies).ToArray(); + CompiledAssemblies = ConvertAssembliesDictToOrderedList(compiledAssemblies, _assembliesToCompile).ToArray(); FileWrites = _fileWrites.ToArray(); return !Log.HasLoggedErrors; } + private IList EnsureAndGetAssembliesInTheSameDir(ITaskItem[] originalAssemblies) + { + string firstAsmDir = Path.GetDirectoryName(originalAssemblies[0].GetMetadata("FullPath")) ?? string.Empty; + bool allInSameDir = originalAssemblies.All(asm => Path.GetDirectoryName(asm.GetMetadata("FullPath")) == firstAsmDir); + if (allInSameDir) + return originalAssemblies.ToList(); + + string aotInPath = Path.Combine(IntermediateOutputPath, "aot-in"); + Directory.CreateDirectory(aotInPath); + + List newAssemblies = new(); + foreach (var origAsm in originalAssemblies) + { + string origPath = origAsm.GetMetadata("FullPath"); + string newPath = Path.Combine(aotInPath, Path.GetFileName(origPath)); + + string? skip = origAsm.GetMetadata("AOT_InternalForceInterpret"); + if (bool.TryParse(skip, out bool shouldSkip) && + shouldSkip && parsedAotMode == MonoAotMode.LLVMOnly) + { + throw new LogAsErrorException($"Builing in AOTMode=LLVMonly is not compatible with excluding any assemblies for AOT. Excluded assembly: {origAsm.ItemSpec}"); + } + + // FIXME: delete files not in originalAssemblies though + // FIXME: or .. just delete the whole dir? + if (Utils.CopyIfDifferent(origPath, newPath, useHash: true)) + Log.LogMessage(MessageImportance.Low, $"Copying {origPath} to {newPath}"); + + ITaskItem newAsm = new TaskItem(newPath); + origAsm.CopyMetadataTo(newAsm); + newAssemblies.Add(newAsm); + } + + return newAssemblies; + } + private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths) { string assembly = assemblyItem.GetMetadata("FullPath"); @@ -567,38 +631,20 @@ private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths) // values, which wont work. processArgs.Add($"\"--aot={string.Join(",", aotArgs)}\""); - string paths = ""; if (isDedup) { - StringBuilder sb = new StringBuilder(); - HashSet allPaths = new HashSet(); - foreach (var aItem in Assemblies) - { - string filename = aItem.ItemSpec; - processArgs.Add(filename); - string dir = Path.GetDirectoryName(filename)!; - if (!allPaths.Contains(dir)) - { - allPaths.Add(dir); - if (sb.Length > 0) - sb.Append(Path.PathSeparator); - sb.Append(dir); - } - } - if (sb.Length > 0) - sb.Append(Path.PathSeparator); - sb.Append(monoPaths); - paths = sb.ToString(); + foreach (var aItem in _assembliesToCompile!) + processArgs.Add(aItem.ItemSpec); } else { - paths = $"{assemblyDir}{Path.PathSeparator}{monoPaths}"; processArgs.Add('"' + assemblyFilename + '"'); } + monoPaths = $"{assemblyDir}{Path.PathSeparator}{monoPaths}"; var envVariables = new Dictionary { - {"MONO_PATH", paths}, + {"MONO_PATH", monoPaths }, {"MONO_ENV_OPTIONS", string.Empty} // we do not want options to be provided out of band to the cross compilers }; @@ -713,7 +759,7 @@ private void PrecompileLibraryParallel(ITaskItem assemblyItem, string? monoPaths state.Break(); } - private bool GenerateAotModulesTable(ITaskItem[] assemblies, string[]? profilers, string outputFile) + private bool GenerateAotModulesTable(IEnumerable assemblies, string[]? profilers, string outputFile) { var symbols = new List(); foreach (var asm in assemblies) @@ -831,10 +877,10 @@ private bool TryGetAssemblyName(string asmPath, [NotNullWhen(true)] out string? } } - private IList ConvertAssembliesDictToOrderedList(ConcurrentDictionary dict, ITaskItem[] items) + private static IList ConvertAssembliesDictToOrderedList(ConcurrentDictionary dict, IList originalAssemblies) { - List outItems = new(items.Length); - foreach (ITaskItem item in items) + List outItems = new(originalAssemblies.Count); + foreach (ITaskItem item in originalAssemblies) { if (!dict.TryGetValue(item.GetMetadata("FullPath"), out ITaskItem? dictItem)) throw new LogAsErrorException($"Bug: Could not find item in the dict with key {item.ItemSpec}"); diff --git a/src/tasks/Common/Utils.cs b/src/tasks/Common/Utils.cs index 2c1a8b49370c7..2c624214937d6 100644 --- a/src/tasks/Common/Utils.cs +++ b/src/tasks/Common/Utils.cs @@ -212,7 +212,7 @@ public static bool CopyIfDifferent(string src, string dst, bool useHash) throw new ArgumentException($"Cannot find {src} file to copy", nameof(src)); bool areDifferent = !File.Exists(dst) || - (useHash && Utils.ComputeHash(src) != Utils.ComputeHash(dst)) || + (useHash && ComputeHash(src) != ComputeHash(dst)) || (File.ReadAllText(src) != File.ReadAllText(dst)); if (areDifferent) diff --git a/src/tasks/WasmAppBuilder/EmccCompile.cs b/src/tasks/WasmAppBuilder/EmccCompile.cs index 3d166670f14ac..a5d6af6c3b473 100644 --- a/src/tasks/WasmAppBuilder/EmccCompile.cs +++ b/src/tasks/WasmAppBuilder/EmccCompile.cs @@ -146,7 +146,7 @@ private bool ExecuteActual() }); if (!result.IsCompleted && !Log.HasLoggedErrors) - Log.LogError("Unknown failed occured while compiling"); + Log.LogError("Unknown failure occured while compiling. Check logs to get more details."); } if (!Log.HasLoggedErrors) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs index 126efb0c48406..1dcdd21ebe730 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs @@ -41,6 +41,30 @@ public void SimpleNativeBuild(BuildArgs buildArgs, RunHost host, string id) host: host, id: id); } + [Theory] + [BuildAndRun(aot: true, host: RunHost.None)] + public void MonoAOTCross_WorksWithNoTrimming(BuildArgs buildArgs, string id) + { + // stop once `mono-aot-cross` part of the build is done + string target = @" + + "; + + string projectName = $"mono_aot_cross_{buildArgs.Config}_{buildArgs.AOT}"; + + buildArgs = buildArgs with { ProjectName = projectName, ExtraBuildArgs = "-p:PublishTrimmed=false -v:n" }; + buildArgs = ExpandBuildArgs(buildArgs, extraProperties: "true", insertAtEnd: target); + + (_, string output) = BuildProject( + buildArgs, + initProject: () => File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), s_mainReturns42), + dotnetWasmFromRuntimePack: false, + id: id, + expectSuccess: false); + + Assert.Contains("Stopping after AOT", output); + } + [Theory] [BuildAndRun(host: RunHost.None, aot: true)] public void IntermediateBitcodeToObjectFilesAreNotLLVMIR(BuildArgs buildArgs, string id) @@ -73,5 +97,37 @@ public void IntermediateBitcodeToObjectFilesAreNotLLVMIR(BuildArgs buildArgs, st throw new XunitException($"Expected to successfully run wasm-dis on System.Private.CoreLib.dll.o ." + " It might fail if it was incorrectly compiled to a bitcode file, instead of wasm."); } + + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] + [InlineData("Debug")] + [InlineData("Release")] + public void BlazorWasm_CanRunMonoAOTCross_WithNoTrimming(string config) + { + string id = $"blazorwasm_{config}_aot"; + CreateBlazorWasmTemplateProject(id); + + // We don't want to emcc compile, and link ~180 assemblies! + // So, stop once `mono-aot-cross` part of the build is done + string target = @" + + + "; + AddItemsPropertiesToProject(Path.Combine(_projectDir!, $"{id}.csproj"), + extraItems: null, + extraProperties: null, + atTheEnd: target); + + string publishLogPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}.binlog"); + CommandResult res = new DotNetCommand(s_buildEnv) + .WithWorkingDirectory(_projectDir!) + .ExecuteWithCapturedOutput("publish", + $"-bl:{publishLogPath}", + "-p:RunAOTCompilation=true", + "-p:PublishTrimmed=false", + $"-p:Configuration={config}"); + + Assert.True(res.ExitCode != 0, "Expected publish to fail"); + Assert.Contains("Stopping after AOT", res.Output); + } } } From 73efb99d92128bb21bb18f4e3da7b40d8c4da450 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 9 Sep 2021 20:34:54 -0400 Subject: [PATCH 21/46] WasmAppBuilder - cleanup --- eng/Versions.props | 2 +- src/tasks/WasmAppBuilder/WasmAppBuilder.cs | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 1e4784ac30c01..3625c58667625 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -163,7 +163,7 @@ 2.0.4 4.12.0 2.14.3 - 6.0.100-rc.2.21425.12 + 6.0.100-rc.2.21458.9 5.0.0-preview-20201009.2 diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs index c0f1b08d05865..58b4b9259e629 100644 --- a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs +++ b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs @@ -117,11 +117,24 @@ public IcuData(string name) : base(name, "icu") {} } public override bool Execute () + { + try + { + return ExecuteInternal(); + } + catch (LogAsErrorException laee) + { + Log.LogError(laee.Message); + return false; + } + } + + private bool ExecuteInternal () { if (!File.Exists(MainJS)) - throw new ArgumentException($"File MainJS='{MainJS}' doesn't exist."); + throw new LogAsErrorException($"File MainJS='{MainJS}' doesn't exist."); if (!InvariantGlobalization && string.IsNullOrEmpty(IcuDataFileName)) - throw new ArgumentException("IcuDataFileName property shouldn't be empty if InvariantGlobalization=false"); + throw new LogAsErrorException("IcuDataFileName property shouldn't be empty if InvariantGlobalization=false"); if (Assemblies?.Length == 0) { From 5457420a2828983a315c70d488f2ee893fc01fbf Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 9 Sep 2021 20:36:45 -0400 Subject: [PATCH 22/46] Bump sdk for workload testing to 6.0.100-rc.2.21459.15 --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 3625c58667625..1c492f0fb502a 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -163,7 +163,7 @@ 2.0.4 4.12.0 2.14.3 - 6.0.100-rc.2.21458.9 + 6.0.100-rc.2.21459.15 5.0.0-preview-20201009.2 From a93db63a49856130ac17558b0a95ffb24c780d4d Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 9 Sep 2021 20:54:04 -0400 Subject: [PATCH 23/46] disable non-wasm builds --- eng/pipelines/common/platform-matrix.yml | 634 ----------------------- 1 file changed, 634 deletions(-) diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index 15fe948e92967..c61da39747d99 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -27,184 +27,6 @@ parameters: jobs: # Linux arm -- ${{ if or(containsValue(parameters.platforms, 'Linux_arm'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: arm - targetRid: linux-arm - platform: Linux_arm - container: - image: ubuntu-16.04-cross-20210719121212-8a8d3be - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux arm64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: arm64 - targetRid: linux-arm64 - platform: Linux_arm64 - container: - image: ubuntu-16.04-cross-arm64-20210719121212-8a8d3be - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm64' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux musl x64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_x64'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - osSubgroup: _musl - archType: x64 - targetRid: linux-musl-x64 - platform: Linux_musl_x64 - container: - image: alpine-3.9-WithNode-20210714125437-9b5bbc2 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux musl arm - -- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - osSubgroup: _musl - archType: arm - targetRid: linux-musl-arm - platform: Linux_musl_arm - container: - image: ubuntu-16.04-cross-arm-alpine-20210719121212-044d5b9 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux musl arm64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm64'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - osSubgroup: _musl - archType: arm64 - targetRid: linux-musl-arm64 - platform: Linux_musl_arm64 - container: - image: ubuntu-16.04-cross-arm64-alpine-20210719121212-b2c2436 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm64' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux x64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_x64'), containsValue(parameters.platforms, 'CoreClrTestBuildHost'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: x64 - targetRid: linux-x64 - platform: Linux_x64 - container: - image: centos-7-20210714125435-9b5bbc2 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux x64 Source Build - -- ${{ if containsValue(parameters.platforms, 'SourceBuild_Linux_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: x64 - targetRid: linux-x64 - platform: Linux_x64 - container: - image: centos-7-source-build-20210714125450-5d87b80 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - buildingOnSourceBuildImage: true - # WebAssembly - ${{ if containsValue(parameters.platforms, 'Browser_wasm') }}: @@ -250,459 +72,3 @@ jobs: platforms: ${{ parameters.platforms }} ${{ insert }}: ${{ parameters.jobParameters }} -# FreeBSD -- ${{ if containsValue(parameters.platforms, 'FreeBSD_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: FreeBSD - archType: x64 - targetRid: freebsd-x64 - platform: FreeBSD_x64 - container: - image: ubuntu-18.04-cross-freebsd-11-20200407092345-a84b0d2 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - buildConfig: ${{ parameters.buildConfig }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/x64' - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android x64 - -- ${{ if containsValue(parameters.platforms, 'Android_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: x64 - targetRid: android-x64 - platform: Android_x64 - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android x86 - -- ${{ if containsValue(parameters.platforms, 'Android_x86') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: x86 - targetRid: android-x86 - platform: Android_x86 - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android arm - -- ${{ if containsValue(parameters.platforms, 'Android_arm') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: arm - targetRid: android-arm - platform: Android_arm - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android arm64 - -- ${{ if containsValue(parameters.platforms, 'Android_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: arm64 - targetRid: android-arm64 - platform: Android_arm64 - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Mac Catalyst x64 - -- ${{ if containsValue(parameters.platforms, 'MacCatalyst_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: MacCatalyst - archType: x64 - targetRid: maccatalyst-x64 - platform: MacCatalyst_x64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Mac Catalyst arm64 - -- ${{ if containsValue(parameters.platforms, 'MacCatalyst_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: MacCatalyst - archType: arm64 - targetRid: maccatalyst-arm64 - platform: MacCatalyst_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# tvOS arm64 - -- ${{ if containsValue(parameters.platforms, 'tvOS_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: tvOS - archType: arm64 - targetRid: tvos-arm64 - platform: tvOS_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# tvOS Simulator x64 - -- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: tvOSSimulator - archType: x64 - targetRid: tvossimulator-x64 - platform: tvOSSimulator_x64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# tvOS Simulator arm64 - -- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: tvOSSimulator - archType: arm64 - targetRid: tvossimulator-arm64 - platform: tvOSSimulator_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS arm - -- ${{ if containsValue(parameters.platforms, 'iOS_arm') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOS - archType: arm - targetRid: ios-arm - platform: iOS_arm - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS arm64 - -- ${{ if containsValue(parameters.platforms, 'iOS_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOS - archType: arm64 - targetRid: ios-arm64 - platform: iOS_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS Simulator x64 - -- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOSSimulator - archType: x64 - targetRid: iossimulator-x64 - platform: iOSSimulator_x64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS Simulator x86 - -- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x86') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOSSimulator - archType: x86 - targetRid: iossimulator-x86 - platform: iOSsimulator_x86 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - managedTestBuildOsGroup: OSX - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS Simulator arm64 - -- ${{ if containsValue(parameters.platforms, 'iOSSimulator_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOSSimulator - archType: arm64 - targetRid: iossimulator-arm64 - platform: iOSSimulator_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# macOS arm64 - -- ${{ if containsValue(parameters.platforms, 'OSX_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: OSX - archType: arm64 - targetRid: osx-arm64 - platform: OSX_arm64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - ${{ insert }}: ${{ parameters.jobParameters }} - -# macOS x64 - -- ${{ if or(containsValue(parameters.platforms, 'OSX_x64'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: OSX - archType: x64 - targetRid: osx-x64 - platform: OSX_x64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows x64 - -- ${{ if or(containsValue(parameters.platforms, 'windows_x64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: x64 - targetRid: win-x64 - platform: windows_x64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows x86 - -- ${{ if or(containsValue(parameters.platforms, 'windows_x86'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: x86 - targetRid: win-x86 - platform: windows_x86 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows arm -- ${{ if or(containsValue(parameters.platforms, 'windows_arm'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: arm - targetRid: win-arm - platform: windows_arm - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows arm64 - -- ${{ if or(containsValue(parameters.platforms, 'windows_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: arm64 - targetRid: win-arm64 - platform: windows_arm64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} From b5744b41857280a96b3fe8bdf00a4a7ac05e7ceb Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 8 Sep 2021 23:12:49 -0400 Subject: [PATCH 24/46] run blazor tests only with the workloads installed --- src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs index d6ebebd78c2eb..b430449c8c5f7 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs @@ -48,13 +48,13 @@ public void Blazor_BuildThenClean_NativeRelinking(string config) AssertEmptyOrNonExistantDirectory(relinkDir); } - [Theory] + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] [InlineData("Debug")] [InlineData("Release")] public void Blazor_BuildNoNative_ThenBuildNative_ThenClean(string config) => Blazor_BuildNativeNonNative_ThenCleanTest(config, firstBuildNative: false); - [Theory] + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] [InlineData("Debug")] [InlineData("Release")] public void Blazor_BuildNative_ThenBuildNonNative_ThenClean(string config) From 5a5d8edac4b7fe445784eb8547fc5a9021fac1d9 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 8 Sep 2021 23:12:49 -0400 Subject: [PATCH 25/46] Update BlazorOverride.targets to 6.0 --- src/mono/wasm/BlazorOverwrite.targets | 48 +++++++++------------------ 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index c4bcfa156ec44..5c4720897655d 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -34,6 +34,7 @@ Copyright (c) .NET Foundation. All rights reserved. + @@ -120,7 +121,6 @@ Copyright (c) .NET Foundation. All rights reserved. <_BlazorDotnetJsFileName>dotnet.$(_DotNetJsVersion).js - <_DotNetJsItem Remove="@(_DotNetJsItem)" /> <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'"> @@ -133,7 +133,6 @@ Copyright (c) .NET Foundation. All rights reserved. <_DotnetJsStaticWebAssetCandidate Remove="@(_DotnetJsStaticWebAssetCandidate)" /> <_DotnetJsCopyCandidates Remove="@(_DotnetJsCopyCandidates)" /> - + <_DotNetJsItem Remove="@(_DotNetJsItem)" /> <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'"> _framework/$(_BlazorDotnetJsFileName) native @@ -229,11 +229,7 @@ Copyright (c) .NET Foundation. All rights reserved. - - - + <_BlazorEnableTimeZoneSupport>$(BlazorEnableTimeZoneSupport) <_BlazorEnableTimeZoneSupport Condition="'$(_BlazorEnableTimeZoneSupport)' == ''">true @@ -241,16 +237,15 @@ Copyright (c) .NET Foundation. All rights reserved. <_BlazorInvariantGlobalization Condition="'$(_BlazorInvariantGlobalization)' == ''">true <_BlazorCopyOutputSymbolsToOutputDirectory>$(CopyOutputSymbolsToOutputDirectory) <_BlazorCopyOutputSymbolsToOutputDirectory Condition="'$(_BlazorCopyOutputSymbolsToOutputDirectory)'==''">true - + <_BlazorWebAssemblyLoadAllGlobalizationData>$(BlazorWebAssemblyLoadAllGlobalizationData) + <_BlazorWebAssemblyLoadAllGlobalizationData Condition="'$(_BlazorWebAssemblyLoadAllGlobalizationData)' == ''">false - $(OutputPath)$(PublishDirName)\ - - <_BlazorWebAssemblyLoadAllGlobalizationData>$(BlazorWebAssemblyLoadAllGlobalizationData) - <_BlazorWebAssemblyLoadAllGlobalizationData Condition="'$(_BlazorWebAssemblyLoadAllGlobalizationData)' == ''">false + + <_BlazorJSFile Include="$(BlazorWebAssemblyJSPath)" /> <_BlazorJSFile Include="$(BlazorWebAssemblyJSMapPath)" Condition="Exists('$(BlazorWebAssemblyJSMapPath)')" /> @@ -341,14 +336,10 @@ Copyright (c) .NET Foundation. All rights reserved. that change from build to build. Runtime assets contribute to the bulk of the download size. Compressing it has the most benefit while avoiding any ongoing costs to the dev inner loop. --> - - <_GzipFileToCompressForBuild Include="@(_BlazorStaticWebAsset->'%(OriginalItemSpec)')" > - %(Identity) - Alternative - Content-Encoding - gzip - - + + + + - - + - - $(OutputPath)$(PublishDirName)\ - - <_BlazorEnableTimeZoneSupport>$(BlazorEnableTimeZoneSupport) - <_BlazorEnableTimeZoneSupport Condition="'$(_BlazorEnableTimeZoneSupport)' == ''">true - <_BlazorInvariantGlobalization>$(InvariantGlobalization) - <_BlazorInvariantGlobalization Condition="'$(_BlazorInvariantGlobalization)' == ''">true <_BlazorAotEnabled>$(UsingBrowserRuntimeWorkload) <_BlazorAotEnabled Condition="'$(_BlazorAotEnabled)' == ''">false <_BlazorLinkerEnabled>$(PublishTrimmed) @@ -519,10 +502,6 @@ Copyright (c) .NET Foundation. All rights reserved. --> - - - - <_BlazorPublishPrefilteredAssets Include="@(StaticWebAsset)" Condition="'%(StaticWebAsset.AssetTraitName)' == 'BlazorWebAssemblyResource' or '%(StaticWebAsset.AssetTraitName)' == 'Culture' or '%(AssetRole)' == 'Alternative'" /> @@ -630,6 +609,9 @@ Copyright (c) .NET Foundation. All rights reserved. Include="@(StaticWebAsset)" Condition="'%(StaticWebAsset.AssetTraitName)' == 'JSModule' and '%(StaticWebAsset.AssetTraitValue)' == 'JSLibraryModule' and '%(AssetKind)' != 'Build'" /> + + <_BlazorPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" /> + Date: Thu, 9 Sep 2021 23:50:09 -0400 Subject: [PATCH 26/46] [wasm] Fix Publish with VS When publishing with VS, it builds with `$(DeployOnBuild)=true`. That causes `DotNetPublish` to run, which runs `Publish` after `Build`. Wasm targets run `WasmTriggerPublishApp`, that then uses the MSBuild task to invoke `WasmNestedPublishApp, which depends on `Publish`, which depends on `Build`. And that causes `DotNetPublish` again, which results in: ``` sdk/6.0.100-rc.2.21459.15/Sdks/Microsoft.NET.Sdk.Publish/targets/CopyTargets/Microsoft.NET.Sdk.Publish.CopyFiles.targets(80,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "Publish". Since "_CopyAspNetCoreFilesToIntermediateOutputPath" has "DependsOn" dependence on "Publish", the circular is "Publish<-_CopyAspNetCoreFilesToIntermediateOutputPath<-CorePublish<-DotNetPublish<-_PublishBuildAlternative<-Publish". ``` Fix is to unset `DeployOnBuild` for the nested build (`WasmNestedPublishApp`). --- src/mono/wasm/build/WasmApp.targets | 2 +- .../BlazorWasmBuildPublishTests.cs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 3cd642e94d0d0..30a2e81daf635 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -109,7 +109,7 @@ + Properties="_WasmInNestedPublish_UniqueProperty_XYZ=true;;WasmBuildingForPublish=true;DeployOnBuild="> diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index 52df1e1222e4d..178c03f2d863c 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -77,6 +77,25 @@ public void DefaultTemplate_AOT_InProjectFile(string config) BlazorBuild(id, config, NativeFilesType.FromRuntimePack); } + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] + [InlineData("Debug", true)] + [InlineData("Debug", false)] + [InlineData("Release", true)] + [InlineData("Release", false)] + public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRelink) + { + string id = $"blz_deploy_on_build_{config}_{nativeRelink}"; + string projectFile = CreateProjectWithNativeReference(id); + AddItemsPropertiesToProject(projectFile, extraProperties: nativeRelink ? string.Empty : "true"); + + // build with -p:DeployOnBuild=true, and that will trigger a publish + BuildInternal(id, config, publish: false, "-p:DeployOnBuild=true"); + + var expectedFileType = nativeRelink ? NativeFilesType.Relinked : NativeFilesType.AOT; + AssertDotNetNativeFiles(expectedFileType, config, forPublish: true); + AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: false); + } + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] [InlineData("Debug")] [InlineData("Release")] From fda6f1847048e33a770beb0115559b44cbf662b0 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 10 Sep 2021 00:03:07 -0400 Subject: [PATCH 27/46] Revert "disable non-wasm builds" This reverts commit a93db63a49856130ac17558b0a95ffb24c780d4d. --- eng/pipelines/common/platform-matrix.yml | 634 +++++++++++++++++++++++ 1 file changed, 634 insertions(+) diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index c61da39747d99..15fe948e92967 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -27,6 +27,184 @@ parameters: jobs: # Linux arm +- ${{ if or(containsValue(parameters.platforms, 'Linux_arm'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: arm + targetRid: linux-arm + platform: Linux_arm + container: + image: ubuntu-16.04-cross-20210719121212-8a8d3be + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux arm64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: arm64 + targetRid: linux-arm64 + platform: Linux_arm64 + container: + image: ubuntu-16.04-cross-arm64-20210719121212-8a8d3be + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm64' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux musl x64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_x64'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + osSubgroup: _musl + archType: x64 + targetRid: linux-musl-x64 + platform: Linux_musl_x64 + container: + image: alpine-3.9-WithNode-20210714125437-9b5bbc2 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux musl arm + +- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + osSubgroup: _musl + archType: arm + targetRid: linux-musl-arm + platform: Linux_musl_arm + container: + image: ubuntu-16.04-cross-arm-alpine-20210719121212-044d5b9 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux musl arm64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm64'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + osSubgroup: _musl + archType: arm64 + targetRid: linux-musl-arm64 + platform: Linux_musl_arm64 + container: + image: ubuntu-16.04-cross-arm64-alpine-20210719121212-b2c2436 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm64' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux x64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_x64'), containsValue(parameters.platforms, 'CoreClrTestBuildHost'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: x64 + targetRid: linux-x64 + platform: Linux_x64 + container: + image: centos-7-20210714125435-9b5bbc2 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux x64 Source Build + +- ${{ if containsValue(parameters.platforms, 'SourceBuild_Linux_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: x64 + targetRid: linux-x64 + platform: Linux_x64 + container: + image: centos-7-source-build-20210714125450-5d87b80 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + buildingOnSourceBuildImage: true + # WebAssembly - ${{ if containsValue(parameters.platforms, 'Browser_wasm') }}: @@ -72,3 +250,459 @@ jobs: platforms: ${{ parameters.platforms }} ${{ insert }}: ${{ parameters.jobParameters }} +# FreeBSD +- ${{ if containsValue(parameters.platforms, 'FreeBSD_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: FreeBSD + archType: x64 + targetRid: freebsd-x64 + platform: FreeBSD_x64 + container: + image: ubuntu-18.04-cross-freebsd-11-20200407092345-a84b0d2 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + buildConfig: ${{ parameters.buildConfig }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/x64' + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android x64 + +- ${{ if containsValue(parameters.platforms, 'Android_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: x64 + targetRid: android-x64 + platform: Android_x64 + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android x86 + +- ${{ if containsValue(parameters.platforms, 'Android_x86') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: x86 + targetRid: android-x86 + platform: Android_x86 + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android arm + +- ${{ if containsValue(parameters.platforms, 'Android_arm') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: arm + targetRid: android-arm + platform: Android_arm + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android arm64 + +- ${{ if containsValue(parameters.platforms, 'Android_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: arm64 + targetRid: android-arm64 + platform: Android_arm64 + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Mac Catalyst x64 + +- ${{ if containsValue(parameters.platforms, 'MacCatalyst_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: MacCatalyst + archType: x64 + targetRid: maccatalyst-x64 + platform: MacCatalyst_x64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Mac Catalyst arm64 + +- ${{ if containsValue(parameters.platforms, 'MacCatalyst_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: MacCatalyst + archType: arm64 + targetRid: maccatalyst-arm64 + platform: MacCatalyst_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# tvOS arm64 + +- ${{ if containsValue(parameters.platforms, 'tvOS_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: tvOS + archType: arm64 + targetRid: tvos-arm64 + platform: tvOS_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# tvOS Simulator x64 + +- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: tvOSSimulator + archType: x64 + targetRid: tvossimulator-x64 + platform: tvOSSimulator_x64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# tvOS Simulator arm64 + +- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: tvOSSimulator + archType: arm64 + targetRid: tvossimulator-arm64 + platform: tvOSSimulator_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS arm + +- ${{ if containsValue(parameters.platforms, 'iOS_arm') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOS + archType: arm + targetRid: ios-arm + platform: iOS_arm + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS arm64 + +- ${{ if containsValue(parameters.platforms, 'iOS_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOS + archType: arm64 + targetRid: ios-arm64 + platform: iOS_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS Simulator x64 + +- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOSSimulator + archType: x64 + targetRid: iossimulator-x64 + platform: iOSSimulator_x64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS Simulator x86 + +- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x86') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOSSimulator + archType: x86 + targetRid: iossimulator-x86 + platform: iOSsimulator_x86 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + managedTestBuildOsGroup: OSX + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS Simulator arm64 + +- ${{ if containsValue(parameters.platforms, 'iOSSimulator_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOSSimulator + archType: arm64 + targetRid: iossimulator-arm64 + platform: iOSSimulator_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# macOS arm64 + +- ${{ if containsValue(parameters.platforms, 'OSX_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: OSX + archType: arm64 + targetRid: osx-arm64 + platform: OSX_arm64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + ${{ insert }}: ${{ parameters.jobParameters }} + +# macOS x64 + +- ${{ if or(containsValue(parameters.platforms, 'OSX_x64'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: OSX + archType: x64 + targetRid: osx-x64 + platform: OSX_x64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows x64 + +- ${{ if or(containsValue(parameters.platforms, 'windows_x64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: x64 + targetRid: win-x64 + platform: windows_x64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows x86 + +- ${{ if or(containsValue(parameters.platforms, 'windows_x86'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: x86 + targetRid: win-x86 + platform: windows_x86 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows arm +- ${{ if or(containsValue(parameters.platforms, 'windows_arm'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: arm + targetRid: win-arm + platform: windows_arm + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows arm64 + +- ${{ if or(containsValue(parameters.platforms, 'windows_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: arm64 + targetRid: win-arm64 + platform: windows_arm64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} From 8e2ba88b1748c1f313fc8787b48f5821b6670381 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 10 Sep 2021 00:35:30 -0400 Subject: [PATCH 28/46] Fix up blazorOverride.targets --- src/mono/wasm/BlazorOverwrite.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index 5c4720897655d..ef4a63321f9f2 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -245,7 +245,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + <_BlazorJSFile Include="$(BlazorWebAssemblyJSPath)" /> <_BlazorJSFile Include="$(BlazorWebAssemblyJSMapPath)" Condition="Exists('$(BlazorWebAssemblyJSMapPath)')" /> From d011f44bde2dcee8bb364f0d57b1395b49381879 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 10 Sep 2021 00:56:15 -0400 Subject: [PATCH 29/46] Fix local aot builds for samples --- src/mono/sample/wasm/wasm.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/sample/wasm/wasm.mk b/src/mono/sample/wasm/wasm.mk index a40a367831464..e3405dbcc0d0d 100644 --- a/src/mono/sample/wasm/wasm.mk +++ b/src/mono/sample/wasm/wasm.mk @@ -10,7 +10,7 @@ CONFIG?=Release WASM_DEFAULT_BUILD_ARGS?=/p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=$(CONFIG) -all: build +all: publish build: EMSDK_PATH=$(realpath $(TOP)/src/mono/wasm/emsdk) $(DOTNET) build $(DOTNET_Q_ARGS) $(WASM_DEFAULT_BUILD_ARGS) $(MSBUILD_ARGS) $(PROJECT_NAME) From 6a37e25f2ffc6a512a8439f1a3ac60cd9c5f1074 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 10 Sep 2021 05:07:45 -0400 Subject: [PATCH 30/46] Fix aot with no trimming for blazor projects .. and correctly skip assemblies marked for non-aot. --- src/mono/wasm/BlazorOverwrite.targets | 3 +- src/mono/wasm/build/WasmApp.targets | 4 -- src/tasks/AotCompilerTask/MonoAOTCompiler.cs | 53 +++++++++++++------ .../BlazorWasmBuildPublishTests.cs | 13 ++++- .../Wasm.Build.Tests/BuildTestBase.cs | 10 ++++ .../Wasm.Build.Tests/CleanTests.cs | 2 +- 6 files changed, 61 insertions(+), 24 deletions(-) diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index ef4a63321f9f2..21af00350fa09 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -226,6 +226,7 @@ Copyright (c) .NET Foundation. All rights reserved. + @@ -659,7 +660,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 30a2e81daf635..40c977ff8c331 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -76,10 +76,6 @@ - - - @(_AOT_AssembliesForceToInterpret) - Assemblies to exclude from AOT - note: This is not compatible with AOTMode=LLVMOnly . - --> diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index 58e1213bdcb24..c5256800a64f7 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -211,7 +211,6 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task private int _numCompiled; private int _totalNumAssemblies; - private bool ProcessAndValidateArguments() { if (!File.Exists(CompilerBinaryPath)) @@ -401,10 +400,31 @@ private bool ExecuteInternal() private IList EnsureAndGetAssembliesInTheSameDir(ITaskItem[] originalAssemblies) { + List filteredAssemblies = new(); string firstAsmDir = Path.GetDirectoryName(originalAssemblies[0].GetMetadata("FullPath")) ?? string.Empty; - bool allInSameDir = originalAssemblies.All(asm => Path.GetDirectoryName(asm.GetMetadata("FullPath")) == firstAsmDir); + bool allInSameDir = true; + + foreach (var origAsm in originalAssemblies) + { + if (allInSameDir && Path.GetDirectoryName(origAsm.GetMetadata("FullPath")) != firstAsmDir) + allInSameDir = false; + + if (ShouldSkip(origAsm)) + { + if (parsedAotMode == MonoAotMode.LLVMOnly) + throw new LogAsErrorException($"Building in AOTMode=LLVMonly is not compatible with excluding any assemblies for AOT. Excluded assembly: {origAsm.ItemSpec}"); + + Log.LogMessage(MessageImportance.Low, $"Skipping {origAsm.ItemSpec} because it has %(AOT_InternalForceToInterpret)=true"); + continue; + } + + filteredAssemblies.Add(origAsm); + } + if (allInSameDir) - return originalAssemblies.ToList(); + return filteredAssemblies; + + // Copy to aot-in string aotInPath = Path.Combine(IntermediateOutputPath, "aot-in"); Directory.CreateDirectory(aotInPath); @@ -412,27 +432,26 @@ private IList EnsureAndGetAssembliesInTheSameDir(ITaskItem[] original List newAssemblies = new(); foreach (var origAsm in originalAssemblies) { - string origPath = origAsm.GetMetadata("FullPath"); - string newPath = Path.Combine(aotInPath, Path.GetFileName(origPath)); - - string? skip = origAsm.GetMetadata("AOT_InternalForceInterpret"); - if (bool.TryParse(skip, out bool shouldSkip) && - shouldSkip && parsedAotMode == MonoAotMode.LLVMOnly) - { - throw new LogAsErrorException($"Builing in AOTMode=LLVMonly is not compatible with excluding any assemblies for AOT. Excluded assembly: {origAsm.ItemSpec}"); - } + string asmPath = origAsm.GetMetadata("FullPath"); + string newPath = Path.Combine(aotInPath, Path.GetFileName(asmPath)); // FIXME: delete files not in originalAssemblies though // FIXME: or .. just delete the whole dir? - if (Utils.CopyIfDifferent(origPath, newPath, useHash: true)) - Log.LogMessage(MessageImportance.Low, $"Copying {origPath} to {newPath}"); + if (Utils.CopyIfDifferent(asmPath, newPath, useHash: true)) + Log.LogMessage(MessageImportance.Low, $"Copying {asmPath} to {newPath}"); - ITaskItem newAsm = new TaskItem(newPath); - origAsm.CopyMetadataTo(newAsm); - newAssemblies.Add(newAsm); + if (!ShouldSkip(origAsm)) + { + ITaskItem newAsm = new TaskItem(newPath); + origAsm.CopyMetadataTo(newAsm); + newAssemblies.Add(newAsm); + } } return newAssemblies; + + static bool ShouldSkip(ITaskItem asmItem) + => bool.TryParse(asmItem.GetMetadata("AOT_InternalForceToInterpret"), out bool skip) && skip; } private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index 178c03f2d863c..9797086f40898 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -89,11 +89,22 @@ public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRel AddItemsPropertiesToProject(projectFile, extraProperties: nativeRelink ? string.Empty : "true"); // build with -p:DeployOnBuild=true, and that will trigger a publish - BuildInternal(id, config, publish: false, "-p:DeployOnBuild=true"); + (CommandResult res, _) = BuildInternal(id, config, publish: false, "-p:DeployOnBuild=true"); var expectedFileType = nativeRelink ? NativeFilesType.Relinked : NativeFilesType.AOT; + AssertDotNetNativeFiles(expectedFileType, config, forPublish: true); AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: false); + + if (expectedFileType == NativeFilesType.AOT) + { + // check for this too, so we know the format is correct for the negative + // test for jsinterop.webassembly.dll + Assert.Contains("Microsoft.JSInterop.dll -> Microsoft.JSInterop.dll.bc", res.Output); + + // make sure this assembly gets skipped + Assert.DoesNotContain("Microsoft.JSInterop.WebAssembly.dll -> Microsoft.JSInterop.WebAssembly.dll.bc", res.Output); + } } [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index b2f9e939beeae..88cbdcaf6b21f 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -401,6 +401,16 @@ public string CreateBlazorWasmTemplateProject(string id) var res = BuildInternal(id, config, publish: true, extraArgs); AssertDotNetNativeFiles(expectedFileType, config, forPublish: true); AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: expectedFileType == NativeFilesType.FromRuntimePack); + + if (expectedFileType == NativeFilesType.AOT) + { + // check for this too, so we know the format is correct for the negative + // test for jsinterop.webassembly.dll + Assert.Contains("Microsoft.JSInterop.dll -> Microsoft.JSInterop.dll.bc", res.Item1.Output); + + // make sure this assembly gets skipped + Assert.DoesNotContain("Microsoft.JSInterop.WebAssembly.dll -> Microsoft.JSInterop.WebAssembly.dll.bc", res.Item1.Output); + } return res; } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs index b430449c8c5f7..d2226d5caadab 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/CleanTests.cs @@ -20,7 +20,7 @@ public CleanTests(ITestOutputHelper output, SharedBuildPerTestClassFixture build { } - [Theory] + [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] [InlineData("Debug")] [InlineData("Release")] public void Blazor_BuildThenClean_NativeRelinking(string config) From 6fc4bbc51f762771a5268118ad27aea846b10cf8 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 10 Sep 2021 07:17:15 -0400 Subject: [PATCH 31/46] Wasm.Build.Test: find differently cased publish dir `Expected to find /datadisks/disk1/work/AF47099B/w/AABA0938/e/blz_deploy_on_build_Debug_True/bin/Debug/net6.0/publish/wwwroot/_framework/dotnet.wasm` .. though the path from the logs: `bin/Debug/net6.0/Publish/wwwroot/_framework/dotnet.wasm` .. with the publish dir case being `publish` vs `Publish`, and so the test fails on linux, as it is looking for `publish`. --- .../Wasm.Build.Tests/BuildTestBase.cs | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index 88cbdcaf6b21f..723413b49cc0d 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -586,7 +586,7 @@ protected static void AssertFile(string file0, string file1, string? label=null, protected void AssertBlazorBundle(string config, bool isPublish, bool dotnetWasmFromRuntimePack, string? binFrameworkDir=null) { - binFrameworkDir ??= Path.Combine(_projectDir!, "bin", config, "net6.0", isPublish ? "publish" : "", "wwwroot", "_framework"); + binFrameworkDir ??= FindBlazorBinFrameworkDir(config, isPublish); AssertBlazorBootJson(config, isPublish, binFrameworkDir: binFrameworkDir); AssertFile(Path.Combine(s_buildEnv.RuntimeNativeDir, "dotnet.wasm"), @@ -605,7 +605,7 @@ protected void AssertBlazorBundle(string config, bool isPublish, bool dotnetWasm protected void AssertBlazorBootJson(string config, bool isPublish, string? binFrameworkDir=null) { - binFrameworkDir ??= Path.Combine(_projectDir!, "bin", config, "net6.0", isPublish ? "publish" : "", "wwwroot", "_framework"); + binFrameworkDir ??= FindBlazorBinFrameworkDir(config, isPublish); string bootJson = File.ReadAllText(Path.Combine(binFrameworkDir, "blazor.boot.json")); var bootJsonNode = JsonNode.Parse(bootJson); @@ -619,6 +619,28 @@ protected void AssertBlazorBootJson(string config, bool isPublish, string? binFr $"{msgPrefix} Could not find dotnet.*js in {bootJson}"); } + protected string FindBlazorBinFrameworkDir(string config, bool forPublish) + { + string basePath = Path.Combine(_projectDir!, "bin", config, "net6.0"); + if (forPublish) + basePath = FindSubDirIgnoringCase(basePath, "publish"); + + return Path.Combine(basePath, "wwwroot", "_framework"); + } + + private string FindSubDirIgnoringCase(string parentDir, string dirName) + { + IEnumerable matchingDirs = Directory.EnumerateDirectories(parentDir, + dirName, + new EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive }); + + string? first = matchingDirs.FirstOrDefault(); + if (matchingDirs.Count() > 1) + throw new Exception($"Found multiple directories with names that differ only in case. {string.Join(", ", matchingDirs.ToArray())}"); + + return first ?? Path.Combine(parentDir, dirName); + } + protected string GetBinDir(string config, string targetFramework=s_targetFramework, string? baseDir=null) { var dir = baseDir ?? _projectDir; From 5d53a503cb4289311b07fd51c13a08b7c5779c88 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 10 Sep 2021 18:23:28 -0400 Subject: [PATCH 32/46] Rename WasmBuildingForPublish->WasmBuildingForNestedPublish to be clearer --- src/mono/wasm/BlazorOverwrite.targets | 2 +- src/mono/wasm/build/README.md | 2 +- src/mono/wasm/build/WasmApp.InTree.targets | 2 +- src/mono/wasm/build/WasmApp.Native.targets | 4 ++-- src/mono/wasm/build/WasmApp.targets | 20 +++++++++---------- .../Wasm.Build.Tests/NativeBuildTests.cs | 4 ++-- .../WasmNativeDefaultsTests.cs | 12 +++++------ 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index 21af00350fa09..01f37fbba407a 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -487,7 +487,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + <_BlazorAotEnabled>$(UsingBrowserRuntimeWorkload) <_BlazorAotEnabled Condition="'$(_BlazorAotEnabled)' == ''">false diff --git a/src/mono/wasm/build/README.md b/src/mono/wasm/build/README.md index 0a00d77325a40..312b5308645c3 100644 --- a/src/mono/wasm/build/README.md +++ b/src/mono/wasm/build/README.md @@ -40,7 +40,7 @@ Implementation: - By default `WasmTriggerPublishApp` runs after the `Publish` target, and that triggers the nested build - The nested build runs `WasmNestedPublishApp`, which causes `Build`, and `Publish` targets to be run - Because this causes `Build` to be run again, if you have any targets that get triggered by that, then they will be running twice. - - But the original *build* run, and this *publish* run can be differentiated using `$(WasmBuildingForPublish)` + - But the original *build* run, and this *publish* run can be differentiated using `$(WasmBuildingForNestedPublish)` - `WasmTriggerPublishApp` essentially just invokes the nested publish - This runs after `Publish` diff --git a/src/mono/wasm/build/WasmApp.InTree.targets b/src/mono/wasm/build/WasmApp.InTree.targets index 0cc7e857a5afd..f8c26080f0268 100644 --- a/src/mono/wasm/build/WasmApp.InTree.targets +++ b/src/mono/wasm/build/WasmApp.InTree.targets @@ -35,7 +35,7 @@ diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets index 8ddcce7af04ee..1c282834433a6 100644 --- a/src/mono/wasm/build/WasmApp.Native.targets +++ b/src/mono/wasm/build/WasmApp.Native.targets @@ -102,7 +102,7 @@ Text="$(_EMSDKMissingErrorMessage) Emscripten SDK is required for AOT'ing assemblies." /> - + true @@ -111,7 +111,7 @@ - + true true diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 40c977ff8c331..ca44cf76d1ad4 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -90,7 +90,7 @@ true Build - Publish + Publish <_WasmNestedPublishAppPreTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish true @@ -100,12 +100,12 @@ + Condition="'$(IsWasmProject)' == 'true' and '$(WasmBuildingForNestedPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'"> + Properties="_WasmInNestedPublish_UniqueProperty_XYZ=true;;WasmBuildingForNestedPublish=true;DeployOnBuild="> @@ -121,7 +121,7 @@ @@ -130,7 +130,7 @@ - + <_WasmRuntimeConfigFilePath Condition="$([System.String]::new(%(PublishItemsOutputGroupOutputs.Identity)).EndsWith('$(AssemblyName).runtimeconfig.json'))">@(PublishItemsOutputGroupOutputs) @@ -151,7 +151,7 @@ + Condition="'$(IsWasmProject)' == 'true' and '$(WasmBuildingForNestedPublish)' == '' and '$(WasmBuildOnlyAfterPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'" /> $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include')) <_WasmRuntimePackSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src')) - <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForPublish)' == ''">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'for-build')) - <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForPublish)' != ''">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'for-publish')) + <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForNestedPublish)' == ''">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'for-build')) + <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForNestedPublish)' != ''">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'for-publish')) <_DriverGenCPath>$(_WasmIntermediateOutputPath)driver-gen.c - <_WasmShouldAOT Condition="'$(WasmBuildingForPublish)' == 'true' and '$(RunAOTCompilation)' == 'true'">true + <_WasmShouldAOT Condition="'$(WasmBuildingForNestedPublish)' == 'true' and '$(RunAOTCompilation)' == 'true'">true <_WasmShouldAOT Condition="'$(RunAOTCompilationAfterBuild)' == 'true' and '$(RunAOTCompilation)' == 'true'">true <_WasmShouldAOT Condition="'$(_WasmShouldAOT)' == ''">false @@ -179,7 +179,7 @@ - + diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs index 1dcdd21ebe730..3453f9922dbba 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeBuildTests.cs @@ -47,7 +47,7 @@ public void MonoAOTCross_WorksWithNoTrimming(BuildArgs buildArgs, string id) { // stop once `mono-aot-cross` part of the build is done string target = @" - + "; string projectName = $"mono_aot_cross_{buildArgs.Config}_{buildArgs.AOT}"; @@ -109,7 +109,7 @@ public void BlazorWasm_CanRunMonoAOTCross_WithNoTrimming(string config) // We don't want to emcc compile, and link ~180 assemblies! // So, stop once `mono-aot-cross` part of the build is done string target = @" - + "; AddItemsPropertiesToProject(Path.Combine(_projectDir!, $"{id}.csproj"), diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmNativeDefaultsTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmNativeDefaultsTests.cs index 8880fd27b9d8c..64d008549e8ec 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmNativeDefaultsTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmNativeDefaultsTests.cs @@ -40,8 +40,8 @@ public void Defaults(string config, string extraProperties, bool aot, bool build { string output = CheckWasmNativeDefaultValue("native_defaults_publish", config, extraProperties, aot, dotnetWasmFromRuntimePack: !publishValue); - Assert.Contains($"** WasmBuildNative: '{buildValue.ToString().ToLower()}', WasmBuildingForPublish: ''", output); - Assert.Contains($"** WasmBuildNative: '{publishValue.ToString().ToLower()}', WasmBuildingForPublish: 'true'", output); + Assert.Contains($"** WasmBuildNative: '{buildValue.ToString().ToLower()}', WasmBuildingForNestedPublish: ''", output); + Assert.Contains($"** WasmBuildNative: '{publishValue.ToString().ToLower()}', WasmBuildingForNestedPublish: 'true'", output); Assert.Contains("Stopping the build", output); } @@ -61,8 +61,8 @@ public void WithNativeReference(string config, string extraProperties, bool buil dotnetWasmFromRuntimePack: !publishValue, extraItems: nativeRefItem); - Assert.Contains($"** WasmBuildNative: '{buildValue.ToString().ToLower()}', WasmBuildingForPublish: ''", output); - Assert.Contains($"** WasmBuildNative: '{publishValue.ToString().ToLower()}', WasmBuildingForPublish: 'true'", output); + Assert.Contains($"** WasmBuildNative: '{buildValue.ToString().ToLower()}', WasmBuildingForNestedPublish: ''", output); + Assert.Contains($"** WasmBuildNative: '{publishValue.ToString().ToLower()}', WasmBuildingForNestedPublish: 'true'", output); Assert.Contains("Stopping the build", output); } @@ -78,8 +78,8 @@ private string CheckWasmNativeDefaultValue(string projectName, string printValueTarget = @" - - + + "; BuildArgs buildArgs = new(ProjectName: projectName, Config: config, AOT: aot, string.Empty, null); From d2037c7c6d1ec20e1513f7e8233a7a304c4af965 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 10 Sep 2021 18:24:11 -0400 Subject: [PATCH 33/46] Update BlazorOverwrite.targets 1. Ensure that the PublishDir uses the same case as PublishUrl, to workaround a bug where we end up with two directories on linux: `Publish`, and `publish`. https://github.com/dotnet/sdk/issues/20923 2. Add all the `@(WasmNativeAssets)` as candidates, and not just `.wasm` --- src/mono/wasm/BlazorOverwrite.targets | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index 01f37fbba407a..a276d38572372 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -75,6 +75,9 @@ Copyright (c) .NET Foundation. All rights reserved. ComputeFilesToPublish;_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn) <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' != 'true'">ResolveRuntimePackAssets <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'">WasmBuildApp + + + Publish @@ -267,7 +270,7 @@ Copyright (c) .NET Foundation. All rights reserved. Date: Fri, 10 Sep 2021 18:38:27 -0400 Subject: [PATCH 34/46] sample/iOS: Add new required IntermediateOutputPath parameter for MonoAOTCompiler --- src/mono/sample/iOS/Program.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/sample/iOS/Program.csproj b/src/mono/sample/iOS/Program.csproj index 8c3b217fc9091..64ffef7e16d54 100644 --- a/src/mono/sample/iOS/Program.csproj +++ b/src/mono/sample/iOS/Program.csproj @@ -60,6 +60,7 @@ AotModulesTablePath="$(AppDir)\modules.m" AotModulesTableLanguage="ObjC" OutputDir="$(PublishDir)" + IntermediateOutputPath="$(IntermediateOutputPath)" UseLLVM="$(UseLLVM)" LLVMPath="$(MonoAotCrossDir)"> From 1e67f3e0f430be3c2b1db924feebc06bc9cafb49 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 9 Sep 2021 20:54:04 -0400 Subject: [PATCH 35/46] disable non-wasm builds --- eng/pipelines/common/platform-matrix.yml | 634 ----------------------- 1 file changed, 634 deletions(-) diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index 15fe948e92967..c61da39747d99 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -27,184 +27,6 @@ parameters: jobs: # Linux arm -- ${{ if or(containsValue(parameters.platforms, 'Linux_arm'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: arm - targetRid: linux-arm - platform: Linux_arm - container: - image: ubuntu-16.04-cross-20210719121212-8a8d3be - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux arm64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: arm64 - targetRid: linux-arm64 - platform: Linux_arm64 - container: - image: ubuntu-16.04-cross-arm64-20210719121212-8a8d3be - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm64' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux musl x64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_x64'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - osSubgroup: _musl - archType: x64 - targetRid: linux-musl-x64 - platform: Linux_musl_x64 - container: - image: alpine-3.9-WithNode-20210714125437-9b5bbc2 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux musl arm - -- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - osSubgroup: _musl - archType: arm - targetRid: linux-musl-arm - platform: Linux_musl_arm - container: - image: ubuntu-16.04-cross-arm-alpine-20210719121212-044d5b9 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux musl arm64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm64'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - osSubgroup: _musl - archType: arm64 - targetRid: linux-musl-arm64 - platform: Linux_musl_arm64 - container: - image: ubuntu-16.04-cross-arm64-alpine-20210719121212-b2c2436 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm64' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux x64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_x64'), containsValue(parameters.platforms, 'CoreClrTestBuildHost'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: x64 - targetRid: linux-x64 - platform: Linux_x64 - container: - image: centos-7-20210714125435-9b5bbc2 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux x64 Source Build - -- ${{ if containsValue(parameters.platforms, 'SourceBuild_Linux_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: x64 - targetRid: linux-x64 - platform: Linux_x64 - container: - image: centos-7-source-build-20210714125450-5d87b80 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - buildingOnSourceBuildImage: true - # WebAssembly - ${{ if containsValue(parameters.platforms, 'Browser_wasm') }}: @@ -250,459 +72,3 @@ jobs: platforms: ${{ parameters.platforms }} ${{ insert }}: ${{ parameters.jobParameters }} -# FreeBSD -- ${{ if containsValue(parameters.platforms, 'FreeBSD_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: FreeBSD - archType: x64 - targetRid: freebsd-x64 - platform: FreeBSD_x64 - container: - image: ubuntu-18.04-cross-freebsd-11-20200407092345-a84b0d2 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - buildConfig: ${{ parameters.buildConfig }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/x64' - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android x64 - -- ${{ if containsValue(parameters.platforms, 'Android_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: x64 - targetRid: android-x64 - platform: Android_x64 - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android x86 - -- ${{ if containsValue(parameters.platforms, 'Android_x86') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: x86 - targetRid: android-x86 - platform: Android_x86 - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android arm - -- ${{ if containsValue(parameters.platforms, 'Android_arm') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: arm - targetRid: android-arm - platform: Android_arm - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android arm64 - -- ${{ if containsValue(parameters.platforms, 'Android_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: arm64 - targetRid: android-arm64 - platform: Android_arm64 - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Mac Catalyst x64 - -- ${{ if containsValue(parameters.platforms, 'MacCatalyst_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: MacCatalyst - archType: x64 - targetRid: maccatalyst-x64 - platform: MacCatalyst_x64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Mac Catalyst arm64 - -- ${{ if containsValue(parameters.platforms, 'MacCatalyst_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: MacCatalyst - archType: arm64 - targetRid: maccatalyst-arm64 - platform: MacCatalyst_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# tvOS arm64 - -- ${{ if containsValue(parameters.platforms, 'tvOS_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: tvOS - archType: arm64 - targetRid: tvos-arm64 - platform: tvOS_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# tvOS Simulator x64 - -- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: tvOSSimulator - archType: x64 - targetRid: tvossimulator-x64 - platform: tvOSSimulator_x64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# tvOS Simulator arm64 - -- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: tvOSSimulator - archType: arm64 - targetRid: tvossimulator-arm64 - platform: tvOSSimulator_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS arm - -- ${{ if containsValue(parameters.platforms, 'iOS_arm') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOS - archType: arm - targetRid: ios-arm - platform: iOS_arm - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS arm64 - -- ${{ if containsValue(parameters.platforms, 'iOS_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOS - archType: arm64 - targetRid: ios-arm64 - platform: iOS_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS Simulator x64 - -- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOSSimulator - archType: x64 - targetRid: iossimulator-x64 - platform: iOSSimulator_x64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS Simulator x86 - -- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x86') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOSSimulator - archType: x86 - targetRid: iossimulator-x86 - platform: iOSsimulator_x86 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - managedTestBuildOsGroup: OSX - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS Simulator arm64 - -- ${{ if containsValue(parameters.platforms, 'iOSSimulator_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOSSimulator - archType: arm64 - targetRid: iossimulator-arm64 - platform: iOSSimulator_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# macOS arm64 - -- ${{ if containsValue(parameters.platforms, 'OSX_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: OSX - archType: arm64 - targetRid: osx-arm64 - platform: OSX_arm64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - ${{ insert }}: ${{ parameters.jobParameters }} - -# macOS x64 - -- ${{ if or(containsValue(parameters.platforms, 'OSX_x64'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: OSX - archType: x64 - targetRid: osx-x64 - platform: OSX_x64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows x64 - -- ${{ if or(containsValue(parameters.platforms, 'windows_x64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: x64 - targetRid: win-x64 - platform: windows_x64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows x86 - -- ${{ if or(containsValue(parameters.platforms, 'windows_x86'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: x86 - targetRid: win-x86 - platform: windows_x86 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows arm -- ${{ if or(containsValue(parameters.platforms, 'windows_arm'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: arm - targetRid: win-arm - platform: windows_arm - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows arm64 - -- ${{ if or(containsValue(parameters.platforms, 'windows_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: arm64 - targetRid: win-arm64 - platform: windows_arm64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} From 7cfc9cf7559e6bc27b33a91581e5ec70fafb4319 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 10 Sep 2021 21:07:44 -0400 Subject: [PATCH 36/46] Fix more wasm.build.tests to work around blazor's Publish dir issue --- .../Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs | 6 ++---- .../BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs | 2 +- .../BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs | 11 +++++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index 9797086f40898..f965ee8394d96 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -29,13 +29,11 @@ public void DefaultTemplate_WithoutWorkload(string config) // Build BuildInternal(id, config, publish: false); - string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", "wwwroot", "_framework"); - AssertBlazorBootJson(config, isPublish: false, binFrameworkDir); + AssertBlazorBootJson(config, isPublish: false); // Publish BuildInternal(id, config, publish: true); - binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", "publish", "wwwroot", "_framework"); - AssertBlazorBootJson(config, isPublish: true, binFrameworkDir); + AssertBlazorBootJson(config, isPublish: true); } [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs index 37320c53e0ad8..6c7e3ed788be5 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs @@ -133,7 +133,7 @@ private void BuildNet50Project(string config, bool aot, bool expectError, string result.EnsureSuccessful(); Assert.Contains("** UsingBrowserRuntimeWorkload: 'false'", result.Output); - string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net5.0", "publish", "wwwroot", "_framework"); + string binFrameworkDir = FindBlazorBinFrameworkDir(config, forPublish: true, framework: "net5.0"); AssertBlazorBootJson(config, isPublish: true, binFrameworkDir: binFrameworkDir); // dotnet.wasm here would be from 5.0 nuget like: // /Users/radical/.nuget/packages/microsoft.netcore.app.runtime.browser-wasm/5.0.9/runtimes/browser-wasm/native/dotnet.wasm diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index 723413b49cc0d..b6fab5c6c434b 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -441,7 +441,7 @@ protected void AssertDotNetNativeFiles(NativeFilesType type, string config, bool { string label = forPublish ? "publish" : "build"; string objBuildDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", forPublish ? "for-publish" : "for-build"); - string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", forPublish ? "publish" : "", "wwwroot", "_framework"); + string binFrameworkDir = FindBlazorBinFrameworkDir(config, forPublish); string srcDir = type switch { @@ -607,7 +607,10 @@ protected void AssertBlazorBootJson(string config, bool isPublish, string? binFr { binFrameworkDir ??= FindBlazorBinFrameworkDir(config, isPublish); - string bootJson = File.ReadAllText(Path.Combine(binFrameworkDir, "blazor.boot.json")); + string bootJsonPath = Path.Combine(binFrameworkDir, "blazor.boot.json"); + Assert.True(File.Exists(bootJsonPath), $"Expected to find {bootJsonPath}"); + + string bootJson = File.ReadAllText(bootJsonPath); var bootJsonNode = JsonNode.Parse(bootJson); var runtimeObj = bootJsonNode?["resources"]?["runtime"]?.AsObject(); Assert.NotNull(runtimeObj); @@ -619,9 +622,9 @@ protected void AssertBlazorBootJson(string config, bool isPublish, string? binFr $"{msgPrefix} Could not find dotnet.*js in {bootJson}"); } - protected string FindBlazorBinFrameworkDir(string config, bool forPublish) + protected string FindBlazorBinFrameworkDir(string config, bool forPublish, string framework="net6.0") { - string basePath = Path.Combine(_projectDir!, "bin", config, "net6.0"); + string basePath = Path.Combine(_projectDir!, "bin", config, framework); if (forPublish) basePath = FindSubDirIgnoringCase(basePath, "publish"); From c1ab08f853a7cd8c615a7a3a1c7cd11ed20280c1 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Sat, 11 Sep 2021 02:15:51 -0400 Subject: [PATCH 37/46] Surface @(FileWrites) from nested publish to the main build --- src/mono/wasm/build/WasmApp.targets | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index ca44cf76d1ad4..7bf7ca8d0c6d0 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -115,6 +115,8 @@ + + @@ -122,11 +124,12 @@ + Returns="@(WasmNativeAsset);@(WasmAssembliesFinal);@(FileWrites)"> + From a8f1eaec4de7e9c5a550c4586145bc02e420b9b5 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Sat, 11 Sep 2021 02:36:45 -0400 Subject: [PATCH 38/46] [wasm] Don't relink after build, when `$(DeployOnBuild)=true` When publishing from VS, it builds the project with `$(DeployOnBuild)=true`, in which case we can skip relinking after Build, and instead do it only after publish. Fixes https://github.com/dotnet/runtime/issues/58973 --- src/mono/wasm/build/WasmApp.targets | 1 + .../Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 7bf7ca8d0c6d0..9c96d759a228a 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -94,6 +94,7 @@ <_WasmNestedPublishAppPreTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish true + true diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index f965ee8394d96..f1f30ca206594 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -103,6 +103,18 @@ public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRel // make sure this assembly gets skipped Assert.DoesNotContain("Microsoft.JSInterop.WebAssembly.dll -> Microsoft.JSInterop.WebAssembly.dll.bc", res.Output); } + + // Check that we linked only for publish + string objBuildDir = Path.Combine(_projectDir!, "obj", config, "net6.0", "wasm", "for-build"); + Assert.False(Directory.Exists(objBuildDir), $"Found unexpected {objBuildDir}, which gets creating when relinking during Build"); + + // double check! + int index = res.Output.IndexOf("pinvoke.c -> pinvoke.o"); + Assert.NotEqual(-1, index); + + // there should be only one instance of this string! + index = res.Output.IndexOf("pinvoke.c -> pinvoke.o", index + 1); + Assert.Equal(-1, index); } [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] From c6cbe0ba55af69ee81e5267e69514288e49968bb Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Sat, 11 Sep 2021 05:02:34 -0400 Subject: [PATCH 39/46] Revert "disable non-wasm builds" This reverts commit 1e67f3e0f430be3c2b1db924feebc06bc9cafb49. --- eng/pipelines/common/platform-matrix.yml | 634 +++++++++++++++++++++++ 1 file changed, 634 insertions(+) diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index c61da39747d99..15fe948e92967 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -27,6 +27,184 @@ parameters: jobs: # Linux arm +- ${{ if or(containsValue(parameters.platforms, 'Linux_arm'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: arm + targetRid: linux-arm + platform: Linux_arm + container: + image: ubuntu-16.04-cross-20210719121212-8a8d3be + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux arm64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: arm64 + targetRid: linux-arm64 + platform: Linux_arm64 + container: + image: ubuntu-16.04-cross-arm64-20210719121212-8a8d3be + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm64' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux musl x64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_x64'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + osSubgroup: _musl + archType: x64 + targetRid: linux-musl-x64 + platform: Linux_musl_x64 + container: + image: alpine-3.9-WithNode-20210714125437-9b5bbc2 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux musl arm + +- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + osSubgroup: _musl + archType: arm + targetRid: linux-musl-arm + platform: Linux_musl_arm + container: + image: ubuntu-16.04-cross-arm-alpine-20210719121212-044d5b9 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux musl arm64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm64'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + osSubgroup: _musl + archType: arm64 + targetRid: linux-musl-arm64 + platform: Linux_musl_arm64 + container: + image: ubuntu-16.04-cross-arm64-alpine-20210719121212-b2c2436 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm64' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux x64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_x64'), containsValue(parameters.platforms, 'CoreClrTestBuildHost'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: x64 + targetRid: linux-x64 + platform: Linux_x64 + container: + image: centos-7-20210714125435-9b5bbc2 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux x64 Source Build + +- ${{ if containsValue(parameters.platforms, 'SourceBuild_Linux_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: x64 + targetRid: linux-x64 + platform: Linux_x64 + container: + image: centos-7-source-build-20210714125450-5d87b80 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + buildingOnSourceBuildImage: true + # WebAssembly - ${{ if containsValue(parameters.platforms, 'Browser_wasm') }}: @@ -72,3 +250,459 @@ jobs: platforms: ${{ parameters.platforms }} ${{ insert }}: ${{ parameters.jobParameters }} +# FreeBSD +- ${{ if containsValue(parameters.platforms, 'FreeBSD_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: FreeBSD + archType: x64 + targetRid: freebsd-x64 + platform: FreeBSD_x64 + container: + image: ubuntu-18.04-cross-freebsd-11-20200407092345-a84b0d2 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + buildConfig: ${{ parameters.buildConfig }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/x64' + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android x64 + +- ${{ if containsValue(parameters.platforms, 'Android_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: x64 + targetRid: android-x64 + platform: Android_x64 + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android x86 + +- ${{ if containsValue(parameters.platforms, 'Android_x86') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: x86 + targetRid: android-x86 + platform: Android_x86 + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android arm + +- ${{ if containsValue(parameters.platforms, 'Android_arm') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: arm + targetRid: android-arm + platform: Android_arm + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android arm64 + +- ${{ if containsValue(parameters.platforms, 'Android_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: arm64 + targetRid: android-arm64 + platform: Android_arm64 + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Mac Catalyst x64 + +- ${{ if containsValue(parameters.platforms, 'MacCatalyst_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: MacCatalyst + archType: x64 + targetRid: maccatalyst-x64 + platform: MacCatalyst_x64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Mac Catalyst arm64 + +- ${{ if containsValue(parameters.platforms, 'MacCatalyst_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: MacCatalyst + archType: arm64 + targetRid: maccatalyst-arm64 + platform: MacCatalyst_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# tvOS arm64 + +- ${{ if containsValue(parameters.platforms, 'tvOS_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: tvOS + archType: arm64 + targetRid: tvos-arm64 + platform: tvOS_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# tvOS Simulator x64 + +- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: tvOSSimulator + archType: x64 + targetRid: tvossimulator-x64 + platform: tvOSSimulator_x64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# tvOS Simulator arm64 + +- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: tvOSSimulator + archType: arm64 + targetRid: tvossimulator-arm64 + platform: tvOSSimulator_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS arm + +- ${{ if containsValue(parameters.platforms, 'iOS_arm') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOS + archType: arm + targetRid: ios-arm + platform: iOS_arm + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS arm64 + +- ${{ if containsValue(parameters.platforms, 'iOS_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOS + archType: arm64 + targetRid: ios-arm64 + platform: iOS_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS Simulator x64 + +- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOSSimulator + archType: x64 + targetRid: iossimulator-x64 + platform: iOSSimulator_x64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS Simulator x86 + +- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x86') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOSSimulator + archType: x86 + targetRid: iossimulator-x86 + platform: iOSsimulator_x86 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + managedTestBuildOsGroup: OSX + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS Simulator arm64 + +- ${{ if containsValue(parameters.platforms, 'iOSSimulator_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOSSimulator + archType: arm64 + targetRid: iossimulator-arm64 + platform: iOSSimulator_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# macOS arm64 + +- ${{ if containsValue(parameters.platforms, 'OSX_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: OSX + archType: arm64 + targetRid: osx-arm64 + platform: OSX_arm64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + ${{ insert }}: ${{ parameters.jobParameters }} + +# macOS x64 + +- ${{ if or(containsValue(parameters.platforms, 'OSX_x64'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: OSX + archType: x64 + targetRid: osx-x64 + platform: OSX_x64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows x64 + +- ${{ if or(containsValue(parameters.platforms, 'windows_x64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: x64 + targetRid: win-x64 + platform: windows_x64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows x86 + +- ${{ if or(containsValue(parameters.platforms, 'windows_x86'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: x86 + targetRid: win-x86 + platform: windows_x86 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows arm +- ${{ if or(containsValue(parameters.platforms, 'windows_arm'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: arm + targetRid: win-arm + platform: windows_arm + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows arm64 + +- ${{ if or(containsValue(parameters.platforms, 'windows_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: arm64 + targetRid: win-arm64 + platform: windows_arm64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} From 48085f2d0683948c1d53958e62820515f502e059 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 14 Sep 2021 12:46:24 -0400 Subject: [PATCH 40/46] Update BlazorOverwrite.targets to work with rc2 --- src/mono/wasm/BlazorOverwrite.targets | 120 ++------------------------ 1 file changed, 5 insertions(+), 115 deletions(-) diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index a276d38572372..5aea853dfcd7a 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -73,11 +73,6 @@ Copyright (c) .NET Foundation. All rights reserved. true false ComputeFilesToPublish;_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn) - <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' != 'true'">ResolveRuntimePackAssets - <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'">WasmBuildApp - - - Publish @@ -114,115 +109,6 @@ Copyright (c) .NET Foundation. All rights reserved. - - - - <_DotNetJsVersion>$(BundledNETCoreAppPackageVersion) - <_DotNetJsVersion Condition="'$(RuntimeFrameworkVersion)' != ''">$(RuntimeFrameworkVersion) - <_BlazorDotnetJsFileName>dotnet.$(_DotNetJsVersion).js - - - - <_DotNetJsItem Remove="@(_DotNetJsItem)" /> - <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'"> - _framework/$(_BlazorDotnetJsFileName) - native - true - - - - - <_DotnetJsStaticWebAssetCandidate Remove="@(_DotnetJsStaticWebAssetCandidate)" /> - <_DotnetJsCopyCandidates Remove="@(_DotnetJsCopyCandidates)" /> - - - - - - - - - - - - <_DotnetJsStaticWebAsset Include="@(_DotnetJsStaticWebAssetCandidate->'%(ContentRoot)_framework\dotnet.js')" /> - <_BlazorStaticWebAsset Include="@(_DotnetJsStaticWebAsset)" /> - - - - - - - <_DotNetJsVersion>$(BundledNETCoreAppPackageVersion) - <_DotNetJsVersion Condition="'$(RuntimeFrameworkVersion)' != ''">$(RuntimeFrameworkVersion) - <_BlazorDotnetJsFileName>dotnet.$(_DotNetJsVersion).js - - - - <_DotNetJsItem Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.DestinationSubPath)' == 'dotnet.js' AND '%(ReferenceCopyLocalPaths.AssetType)' == 'native'"> - _framework/$(_BlazorDotnetJsFileName) - - - - - <_DotNetJsItem Remove="@(_DotNetJsItem)" /> - <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'"> - _framework/$(_BlazorDotnetJsFileName) - native - true - - - - - - - - - - - - - <_DotnetJsStaticWebAsset Include="@(_DotnetJsStaticWebAssetCandidate->'%(ContentRoot)_framework\dotnet.js')" /> - <_BlazorStaticWebAsset Include="@(_DotnetJsStaticWebAsset)" /> - - - @@ -265,6 +151,7 @@ Copyright (c) .NET Foundation. All rights reserved. <_BlazorConfigFileCandidates Include="@(StaticWebAsset)" Condition="'%(SourceType)' == 'Discovered'" /> + @@ -278,6 +165,7 @@ Copyright (c) .NET Foundation. All rights reserved. TimeZoneSupport="$(_BlazorEnableTimeZoneSupport)" InvariantGlobalization="$(_BlazorInvariantGlobalization)" CopySymbols="$(_BlazorCopyOutputSymbolsToOutputDirectory)" + BundledNETCoreAppPackageVersion="$(BundledNETCoreAppPackageVersion)" OutputPath="$(OutputPath)" > @@ -490,6 +378,7 @@ Copyright (c) .NET Foundation. All rights reserved. + <_BlazorAotEnabled>$(UsingBrowserRuntimeWorkload) @@ -519,6 +408,7 @@ Copyright (c) .NET Foundation. All rights reserved. InvariantGlobalization="$(_BlazorInvariantGlobalization)" CopySymbols="$(CopyOutputSymbolsToPublishDirectory)" ExistingAssets="@(_BlazorPublishPrefilteredAssets)" + BundledNETCoreAppPackageVersion="$(BundledNETCoreAppPackageVersion)" > @@ -649,7 +539,7 @@ Copyright (c) .NET Foundation. All rights reserved. From 3bba0974971fc98f9f5c44dc952ff1e62806d936 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 14 Sep 2021 13:53:18 -0400 Subject: [PATCH 41/46] [wasm] Disable a blazorwasm publish test `DefaultTemplate_AOT_OnlyWithPublishCommandLine_Then_PublishNoAOT` This test runs build thrice: 1. simple build (no relinking) 2. publish+aot 3. publish-no-aot (relinking) This causes the publish folder to have more than one `dotnet*hash*js` files, which breaks the test since we don't know which one is the "current" one. --- .../BlazorWasmBuildPublishTests.cs | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs index f1f30ca206594..687429a3fca48 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs @@ -117,24 +117,26 @@ public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRel Assert.Equal(-1, index); } - [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] - [InlineData("Debug")] - [InlineData("Release")] - public void DefaultTemplate_AOT_OnlyWithPublishCommandLine_Then_PublishNoAOT(string config) - { - string id = $"blz_aot_pub_{config}"; - CreateBlazorWasmTemplateProject(id); - - // No relinking, no AOT - BlazorBuild(id, config, NativeFilesType.FromRuntimePack); - - // AOT=true only for the publish command line, similar to what - // would happen when setting it in Publish dialog for VS - BlazorPublish(id, config, expectedFileType: NativeFilesType.AOT, "-p:RunAOTCompilation=true"); - - // publish again, no AOT - BlazorPublish(id, config, NativeFilesType.Relinked); - } + // Disabling for now - publish folder can have more than one dotnet*hash*js, and not sure + // how to pick which one to check, for the test + //[ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] + //[InlineData("Debug")] + //[InlineData("Release")] + //public void DefaultTemplate_AOT_OnlyWithPublishCommandLine_Then_PublishNoAOT(string config) + //{ + //string id = $"blz_aot_pub_{config}"; + //CreateBlazorWasmTemplateProject(id); + + //// No relinking, no AOT + //BlazorBuild(id, config, NativeFilesType.FromRuntimePack); + + //// AOT=true only for the publish command line, similar to what + //// would happen when setting it in Publish dialog for VS + //BlazorPublish(id, config, expectedFileType: NativeFilesType.AOT, "-p:RunAOTCompilation=true"); + + //// publish again, no AOT + //BlazorPublish(id, config, NativeFilesType.Relinked); + //} [ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))] [InlineData("Debug")] From 617415f258ccbef9dd25fe2044b543d36213c02d Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 14 Sep 2021 13:59:36 -0400 Subject: [PATCH 42/46] Bump sdk for workload testing to 6.0.100-rc.2.21463.12 --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index a006c03b718fd..eff67b2484813 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -163,7 +163,7 @@ 2.0.4 4.12.0 2.14.3 - 6.0.100-rc.2.21459.15 + 6.0.100-rc.2.21463.12 5.0.0-preview-20201009.2 From ee629017ad96b051d680caca9cc2950834ac8cdd Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 14 Sep 2021 17:36:32 -0400 Subject: [PATCH 43/46] Revert "Update BlazorOverwrite.targets to work with rc2" This reverts commit 48085f2d0683948c1d53958e62820515f502e059. - We want to revert this to a version that works with the currently available SDK, which doesn't have the ComputeBlazorPublishAsset fixes, or the new cache-busting changes. --- src/mono/wasm/BlazorOverwrite.targets | 120 ++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 5 deletions(-) diff --git a/src/mono/wasm/BlazorOverwrite.targets b/src/mono/wasm/BlazorOverwrite.targets index 5aea853dfcd7a..a276d38572372 100644 --- a/src/mono/wasm/BlazorOverwrite.targets +++ b/src/mono/wasm/BlazorOverwrite.targets @@ -73,6 +73,11 @@ Copyright (c) .NET Foundation. All rights reserved. true false ComputeFilesToPublish;_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn) + <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' != 'true'">ResolveRuntimePackAssets + <_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'">WasmBuildApp + + + Publish @@ -109,6 +114,115 @@ Copyright (c) .NET Foundation. All rights reserved. + + + + <_DotNetJsVersion>$(BundledNETCoreAppPackageVersion) + <_DotNetJsVersion Condition="'$(RuntimeFrameworkVersion)' != ''">$(RuntimeFrameworkVersion) + <_BlazorDotnetJsFileName>dotnet.$(_DotNetJsVersion).js + + + + <_DotNetJsItem Remove="@(_DotNetJsItem)" /> + <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'"> + _framework/$(_BlazorDotnetJsFileName) + native + true + + + + + <_DotnetJsStaticWebAssetCandidate Remove="@(_DotnetJsStaticWebAssetCandidate)" /> + <_DotnetJsCopyCandidates Remove="@(_DotnetJsCopyCandidates)" /> + + + + + + + + + + + + <_DotnetJsStaticWebAsset Include="@(_DotnetJsStaticWebAssetCandidate->'%(ContentRoot)_framework\dotnet.js')" /> + <_BlazorStaticWebAsset Include="@(_DotnetJsStaticWebAsset)" /> + + + + + + + <_DotNetJsVersion>$(BundledNETCoreAppPackageVersion) + <_DotNetJsVersion Condition="'$(RuntimeFrameworkVersion)' != ''">$(RuntimeFrameworkVersion) + <_BlazorDotnetJsFileName>dotnet.$(_DotNetJsVersion).js + + + + <_DotNetJsItem Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.DestinationSubPath)' == 'dotnet.js' AND '%(ReferenceCopyLocalPaths.AssetType)' == 'native'"> + _framework/$(_BlazorDotnetJsFileName) + + + + + <_DotNetJsItem Remove="@(_DotNetJsItem)" /> + <_DotNetJsItem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'"> + _framework/$(_BlazorDotnetJsFileName) + native + true + + + + + + + + + + + + + <_DotnetJsStaticWebAsset Include="@(_DotnetJsStaticWebAssetCandidate->'%(ContentRoot)_framework\dotnet.js')" /> + <_BlazorStaticWebAsset Include="@(_DotnetJsStaticWebAsset)" /> + + + @@ -151,7 +265,6 @@ Copyright (c) .NET Foundation. All rights reserved. <_BlazorConfigFileCandidates Include="@(StaticWebAsset)" Condition="'%(SourceType)' == 'Discovered'" /> - @@ -165,7 +278,6 @@ Copyright (c) .NET Foundation. All rights reserved. TimeZoneSupport="$(_BlazorEnableTimeZoneSupport)" InvariantGlobalization="$(_BlazorInvariantGlobalization)" CopySymbols="$(_BlazorCopyOutputSymbolsToOutputDirectory)" - BundledNETCoreAppPackageVersion="$(BundledNETCoreAppPackageVersion)" OutputPath="$(OutputPath)" > @@ -378,7 +490,6 @@ Copyright (c) .NET Foundation. All rights reserved. - <_BlazorAotEnabled>$(UsingBrowserRuntimeWorkload) @@ -408,7 +519,6 @@ Copyright (c) .NET Foundation. All rights reserved. InvariantGlobalization="$(_BlazorInvariantGlobalization)" CopySymbols="$(CopyOutputSymbolsToPublishDirectory)" ExistingAssets="@(_BlazorPublishPrefilteredAssets)" - BundledNETCoreAppPackageVersion="$(BundledNETCoreAppPackageVersion)" > @@ -539,7 +649,7 @@ Copyright (c) .NET Foundation. All rights reserved. From 3da2650b1125660b5c9ae5578b0fa1c485aa1425 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 9 Sep 2021 20:54:04 -0400 Subject: [PATCH 44/46] disable non-wasm builds --- eng/pipelines/common/platform-matrix.yml | 634 ----------------------- 1 file changed, 634 deletions(-) diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index 15fe948e92967..c61da39747d99 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -27,184 +27,6 @@ parameters: jobs: # Linux arm -- ${{ if or(containsValue(parameters.platforms, 'Linux_arm'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: arm - targetRid: linux-arm - platform: Linux_arm - container: - image: ubuntu-16.04-cross-20210719121212-8a8d3be - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux arm64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: arm64 - targetRid: linux-arm64 - platform: Linux_arm64 - container: - image: ubuntu-16.04-cross-arm64-20210719121212-8a8d3be - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm64' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux musl x64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_x64'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - osSubgroup: _musl - archType: x64 - targetRid: linux-musl-x64 - platform: Linux_musl_x64 - container: - image: alpine-3.9-WithNode-20210714125437-9b5bbc2 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux musl arm - -- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - osSubgroup: _musl - archType: arm - targetRid: linux-musl-arm - platform: Linux_musl_arm - container: - image: ubuntu-16.04-cross-arm-alpine-20210719121212-044d5b9 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux musl arm64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm64'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - osSubgroup: _musl - archType: arm64 - targetRid: linux-musl-arm64 - platform: Linux_musl_arm64 - container: - image: ubuntu-16.04-cross-arm64-alpine-20210719121212-b2c2436 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/arm64' - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux x64 - -- ${{ if or(containsValue(parameters.platforms, 'Linux_x64'), containsValue(parameters.platforms, 'CoreClrTestBuildHost'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: x64 - targetRid: linux-x64 - platform: Linux_x64 - container: - image: centos-7-20210714125435-9b5bbc2 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Linux x64 Source Build - -- ${{ if containsValue(parameters.platforms, 'SourceBuild_Linux_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Linux - archType: x64 - targetRid: linux-x64 - platform: Linux_x64 - container: - image: centos-7-source-build-20210714125450-5d87b80 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - buildingOnSourceBuildImage: true - # WebAssembly - ${{ if containsValue(parameters.platforms, 'Browser_wasm') }}: @@ -250,459 +72,3 @@ jobs: platforms: ${{ parameters.platforms }} ${{ insert }}: ${{ parameters.jobParameters }} -# FreeBSD -- ${{ if containsValue(parameters.platforms, 'FreeBSD_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: FreeBSD - archType: x64 - targetRid: freebsd-x64 - platform: FreeBSD_x64 - container: - image: ubuntu-18.04-cross-freebsd-11-20200407092345-a84b0d2 - registry: mcr - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - buildConfig: ${{ parameters.buildConfig }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - crossrootfsDir: '/crossrootfs/x64' - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android x64 - -- ${{ if containsValue(parameters.platforms, 'Android_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: x64 - targetRid: android-x64 - platform: Android_x64 - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android x86 - -- ${{ if containsValue(parameters.platforms, 'Android_x86') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: x86 - targetRid: android-x86 - platform: Android_x86 - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android arm - -- ${{ if containsValue(parameters.platforms, 'Android_arm') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: arm - targetRid: android-arm - platform: Android_arm - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Android arm64 - -- ${{ if containsValue(parameters.platforms, 'Android_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: Android - archType: arm64 - targetRid: android-arm64 - platform: Android_arm64 - container: - image: ubuntu-18.04-android-20200422191843-e2c3f83 - registry: mcr - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Mac Catalyst x64 - -- ${{ if containsValue(parameters.platforms, 'MacCatalyst_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: MacCatalyst - archType: x64 - targetRid: maccatalyst-x64 - platform: MacCatalyst_x64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Mac Catalyst arm64 - -- ${{ if containsValue(parameters.platforms, 'MacCatalyst_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: MacCatalyst - archType: arm64 - targetRid: maccatalyst-arm64 - platform: MacCatalyst_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# tvOS arm64 - -- ${{ if containsValue(parameters.platforms, 'tvOS_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: tvOS - archType: arm64 - targetRid: tvos-arm64 - platform: tvOS_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# tvOS Simulator x64 - -- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: tvOSSimulator - archType: x64 - targetRid: tvossimulator-x64 - platform: tvOSSimulator_x64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# tvOS Simulator arm64 - -- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: tvOSSimulator - archType: arm64 - targetRid: tvossimulator-arm64 - platform: tvOSSimulator_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS arm - -- ${{ if containsValue(parameters.platforms, 'iOS_arm') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOS - archType: arm - targetRid: ios-arm - platform: iOS_arm - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS arm64 - -- ${{ if containsValue(parameters.platforms, 'iOS_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOS - archType: arm64 - targetRid: ios-arm64 - platform: iOS_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS Simulator x64 - -- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOSSimulator - archType: x64 - targetRid: iossimulator-x64 - platform: iOSSimulator_x64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS Simulator x86 - -- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x86') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOSSimulator - archType: x86 - targetRid: iossimulator-x86 - platform: iOSsimulator_x86 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - managedTestBuildOsGroup: OSX - ${{ insert }}: ${{ parameters.jobParameters }} - -# iOS Simulator arm64 - -- ${{ if containsValue(parameters.platforms, 'iOSSimulator_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: iOSSimulator - archType: arm64 - targetRid: iossimulator-arm64 - platform: iOSSimulator_arm64 - jobParameters: - runtimeFlavor: mono - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# macOS arm64 - -- ${{ if containsValue(parameters.platforms, 'OSX_arm64') }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: OSX - archType: arm64 - targetRid: osx-arm64 - platform: OSX_arm64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - crossBuild: true - ${{ insert }}: ${{ parameters.jobParameters }} - -# macOS x64 - -- ${{ if or(containsValue(parameters.platforms, 'OSX_x64'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: OSX - archType: x64 - targetRid: osx-x64 - platform: OSX_x64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows x64 - -- ${{ if or(containsValue(parameters.platforms, 'windows_x64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: x64 - targetRid: win-x64 - platform: windows_x64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows x86 - -- ${{ if or(containsValue(parameters.platforms, 'windows_x86'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: x86 - targetRid: win-x86 - platform: windows_x86 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows arm -- ${{ if or(containsValue(parameters.platforms, 'windows_arm'), eq(parameters.platformGroup, 'all')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: arm - targetRid: win-arm - platform: windows_arm - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} - -# Windows arm64 - -- ${{ if or(containsValue(parameters.platforms, 'windows_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: - - template: xplat-setup.yml - parameters: - jobTemplate: ${{ parameters.jobTemplate }} - helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} - variables: ${{ parameters.variables }} - osGroup: windows - archType: arm64 - targetRid: win-arm64 - platform: windows_arm64 - jobParameters: - runtimeFlavor: ${{ parameters.runtimeFlavor }} - stagedBuild: ${{ parameters.stagedBuild }} - buildConfig: ${{ parameters.buildConfig }} - ${{ if eq(parameters.passPlatforms, true) }}: - platforms: ${{ parameters.platforms }} - helixQueueGroup: ${{ parameters.helixQueueGroup }} - ${{ insert }}: ${{ parameters.jobParameters }} From 4f529612a3a2790a5b6ab911f9a20b62d358e194 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 14 Sep 2021 19:31:14 -0400 Subject: [PATCH 45/46] Address review feedback from @jonathanpeppers --- src/tasks/AotCompilerTask/MonoAOTCompiler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index c5256800a64f7..4ee7389c04df0 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -325,7 +325,7 @@ private bool ProcessAndValidateArguments() throw new LogAsErrorException($"'{nameof(OutputType)}=Library' can not be used with '{nameof(UseStaticLinking)}=true'."); } - return true; + return !Log.HasLoggedErrors; } public override bool Execute() From 981ba33e867b4c0f76b8da2d9c2f16b57e86ca16 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 14 Sep 2021 21:42:30 -0400 Subject: [PATCH 46/46] Revert "disable non-wasm builds" This reverts commit 3da2650b1125660b5c9ae5578b0fa1c485aa1425. --- eng/pipelines/common/platform-matrix.yml | 634 +++++++++++++++++++++++ 1 file changed, 634 insertions(+) diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index c61da39747d99..15fe948e92967 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -27,6 +27,184 @@ parameters: jobs: # Linux arm +- ${{ if or(containsValue(parameters.platforms, 'Linux_arm'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: arm + targetRid: linux-arm + platform: Linux_arm + container: + image: ubuntu-16.04-cross-20210719121212-8a8d3be + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux arm64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: arm64 + targetRid: linux-arm64 + platform: Linux_arm64 + container: + image: ubuntu-16.04-cross-arm64-20210719121212-8a8d3be + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm64' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux musl x64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_x64'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + osSubgroup: _musl + archType: x64 + targetRid: linux-musl-x64 + platform: Linux_musl_x64 + container: + image: alpine-3.9-WithNode-20210714125437-9b5bbc2 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux musl arm + +- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + osSubgroup: _musl + archType: arm + targetRid: linux-musl-arm + platform: Linux_musl_arm + container: + image: ubuntu-16.04-cross-arm-alpine-20210719121212-044d5b9 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux musl arm64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_musl_arm64'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + osSubgroup: _musl + archType: arm64 + targetRid: linux-musl-arm64 + platform: Linux_musl_arm64 + container: + image: ubuntu-16.04-cross-arm64-alpine-20210719121212-b2c2436 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/arm64' + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux x64 + +- ${{ if or(containsValue(parameters.platforms, 'Linux_x64'), containsValue(parameters.platforms, 'CoreClrTestBuildHost'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: x64 + targetRid: linux-x64 + platform: Linux_x64 + container: + image: centos-7-20210714125435-9b5bbc2 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Linux x64 Source Build + +- ${{ if containsValue(parameters.platforms, 'SourceBuild_Linux_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Linux + archType: x64 + targetRid: linux-x64 + platform: Linux_x64 + container: + image: centos-7-source-build-20210714125450-5d87b80 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + buildingOnSourceBuildImage: true + # WebAssembly - ${{ if containsValue(parameters.platforms, 'Browser_wasm') }}: @@ -72,3 +250,459 @@ jobs: platforms: ${{ parameters.platforms }} ${{ insert }}: ${{ parameters.jobParameters }} +# FreeBSD +- ${{ if containsValue(parameters.platforms, 'FreeBSD_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: FreeBSD + archType: x64 + targetRid: freebsd-x64 + platform: FreeBSD_x64 + container: + image: ubuntu-18.04-cross-freebsd-11-20200407092345-a84b0d2 + registry: mcr + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + buildConfig: ${{ parameters.buildConfig }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + crossrootfsDir: '/crossrootfs/x64' + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android x64 + +- ${{ if containsValue(parameters.platforms, 'Android_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: x64 + targetRid: android-x64 + platform: Android_x64 + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android x86 + +- ${{ if containsValue(parameters.platforms, 'Android_x86') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: x86 + targetRid: android-x86 + platform: Android_x86 + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android arm + +- ${{ if containsValue(parameters.platforms, 'Android_arm') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: arm + targetRid: android-arm + platform: Android_arm + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Android arm64 + +- ${{ if containsValue(parameters.platforms, 'Android_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Android + archType: arm64 + targetRid: android-arm64 + platform: Android_arm64 + container: + image: ubuntu-18.04-android-20200422191843-e2c3f83 + registry: mcr + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Mac Catalyst x64 + +- ${{ if containsValue(parameters.platforms, 'MacCatalyst_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: MacCatalyst + archType: x64 + targetRid: maccatalyst-x64 + platform: MacCatalyst_x64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Mac Catalyst arm64 + +- ${{ if containsValue(parameters.platforms, 'MacCatalyst_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: MacCatalyst + archType: arm64 + targetRid: maccatalyst-arm64 + platform: MacCatalyst_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# tvOS arm64 + +- ${{ if containsValue(parameters.platforms, 'tvOS_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: tvOS + archType: arm64 + targetRid: tvos-arm64 + platform: tvOS_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# tvOS Simulator x64 + +- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: tvOSSimulator + archType: x64 + targetRid: tvossimulator-x64 + platform: tvOSSimulator_x64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# tvOS Simulator arm64 + +- ${{ if containsValue(parameters.platforms, 'tvOSSimulator_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: tvOSSimulator + archType: arm64 + targetRid: tvossimulator-arm64 + platform: tvOSSimulator_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS arm + +- ${{ if containsValue(parameters.platforms, 'iOS_arm') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOS + archType: arm + targetRid: ios-arm + platform: iOS_arm + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS arm64 + +- ${{ if containsValue(parameters.platforms, 'iOS_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOS + archType: arm64 + targetRid: ios-arm64 + platform: iOS_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS Simulator x64 + +- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOSSimulator + archType: x64 + targetRid: iossimulator-x64 + platform: iOSSimulator_x64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS Simulator x86 + +- ${{ if containsValue(parameters.platforms, 'iOSSimulator_x86') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOSSimulator + archType: x86 + targetRid: iossimulator-x86 + platform: iOSsimulator_x86 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + managedTestBuildOsGroup: OSX + ${{ insert }}: ${{ parameters.jobParameters }} + +# iOS Simulator arm64 + +- ${{ if containsValue(parameters.platforms, 'iOSSimulator_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: iOSSimulator + archType: arm64 + targetRid: iossimulator-arm64 + platform: iOSSimulator_arm64 + jobParameters: + runtimeFlavor: mono + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# macOS arm64 + +- ${{ if containsValue(parameters.platforms, 'OSX_arm64') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: OSX + archType: arm64 + targetRid: osx-arm64 + platform: OSX_arm64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + crossBuild: true + ${{ insert }}: ${{ parameters.jobParameters }} + +# macOS x64 + +- ${{ if or(containsValue(parameters.platforms, 'OSX_x64'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: OSX + archType: x64 + targetRid: osx-x64 + platform: OSX_x64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows x64 + +- ${{ if or(containsValue(parameters.platforms, 'windows_x64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: x64 + targetRid: win-x64 + platform: windows_x64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows x86 + +- ${{ if or(containsValue(parameters.platforms, 'windows_x86'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: x86 + targetRid: win-x86 + platform: windows_x86 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows arm +- ${{ if or(containsValue(parameters.platforms, 'windows_arm'), eq(parameters.platformGroup, 'all')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: arm + targetRid: win-arm + platform: windows_arm + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Windows arm64 + +- ${{ if or(containsValue(parameters.platforms, 'windows_arm64'), in(parameters.platformGroup, 'all', 'gcstress')) }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: windows + archType: arm64 + targetRid: win-arm64 + platform: windows_arm64 + jobParameters: + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ if eq(parameters.passPlatforms, true) }}: + platforms: ${{ parameters.platforms }} + helixQueueGroup: ${{ parameters.helixQueueGroup }} + ${{ insert }}: ${{ parameters.jobParameters }}