From 2cd8db0e445921a275f65c0c33d6b14c4c002e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 12 Dec 2025 11:50:50 +0100 Subject: [PATCH 01/30] Copy native wasm files to runtime pack --- src/native/corehost/corehost.proj | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj index 8b20592f5fd6f8..d1762eb9a9a0a5 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -12,6 +12,8 @@ GenerateRuntimeVersionFile $(BuildCoreHostDependsOn);InitializeSourceControlInformationFromSourceControlManager $(BuildCoreHostDependsOn);GenerateEmccExports;ResolveRuntimeFilesFromLocalBuild + BuildCoreHostOnWindows + BuildCoreHostOnUnix $(ArtifactsObjDir)$(TargetRid).$(Configuration)\ $(ArtifactsObjDir)_version.h @@ -169,6 +171,25 @@ + + + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)package.json" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)dotnet.d.ts" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.map" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.js" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.a" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.dat" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)libBrowserHost.a" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)dotnet.native.js" /> + + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)dotnet.native.wasm" /> + + + + + From 0f58a1c665246bf72c29e07c9ffd4f293f8ed0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 12 Dec 2025 12:22:43 +0100 Subject: [PATCH 02/30] Register CoreCLR.sfxproj to get RuntimeList.xml --- src/libraries/pretest.proj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index fa615121c17659..3b41f5d9d0a675 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -26,6 +26,9 @@ + From 301d8045012e03db63e57720e4faf038fff065c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 12 Dec 2025 12:22:58 +0100 Subject: [PATCH 03/30] WasmTestRunner and WasmSymbolicator --- src/libraries/pretest.proj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index 3b41f5d9d0a675..96ed94ed4873a0 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -19,8 +19,8 @@ - - + + Date: Fri, 12 Dec 2025 12:23:30 +0100 Subject: [PATCH 04/30] Don't import Mono NativeBuild targets for CoreCLR --- src/mono/browser/build/WasmApp.InTree.props | 2 +- src/mono/browser/build/WasmApp.InTree.targets | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/browser/build/WasmApp.InTree.props b/src/mono/browser/build/WasmApp.InTree.props index 2fef6aa17d9993..b71807099afa22 100644 --- a/src/mono/browser/build/WasmApp.InTree.props +++ b/src/mono/browser/build/WasmApp.InTree.props @@ -12,7 +12,7 @@ - + library diff --git a/src/mono/browser/build/WasmApp.InTree.targets b/src/mono/browser/build/WasmApp.InTree.targets index fd7704093652c9..75e6db2903874d 100644 --- a/src/mono/browser/build/WasmApp.InTree.targets +++ b/src/mono/browser/build/WasmApp.InTree.targets @@ -7,7 +7,7 @@ - + From 8066b2674c1856e7c188de6934029cd6f85b7138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 12 Dec 2025 12:24:22 +0100 Subject: [PATCH 05/30] Mono Sample with CoreCLR --- src/mono/sample/wasm/Directory.Build.targets | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mono/sample/wasm/Directory.Build.targets b/src/mono/sample/wasm/Directory.Build.targets index baa756debe46da..d381a6bf769421 100644 --- a/src/mono/sample/wasm/Directory.Build.targets +++ b/src/mono/sample/wasm/Directory.Build.targets @@ -1,4 +1,9 @@ + + + $(Nested_RuntimeFlavor) + + @@ -37,6 +42,10 @@ + + + + Date: Fri, 12 Dec 2025 12:25:17 +0100 Subject: [PATCH 06/30] Defaults for CoreCLR on wasm --- src/mono/browser/build/WasmApp.InTree.props | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mono/browser/build/WasmApp.InTree.props b/src/mono/browser/build/WasmApp.InTree.props index b71807099afa22..33a54b83c15236 100644 --- a/src/mono/browser/build/WasmApp.InTree.props +++ b/src/mono/browser/build/WasmApp.InTree.props @@ -14,6 +14,14 @@ + + + false + false + false + false + + library From 15a1b5dc143e36dc7507d78e1d89a294bf4192fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 12 Dec 2025 12:29:29 +0100 Subject: [PATCH 07/30] Placeholder for CoreCLR native build --- src/mono/browser/build/BrowserWasmApp.CoreCLR.targets | 9 +++++++++ src/mono/browser/build/WasmApp.InTree.targets | 1 + 2 files changed, 10 insertions(+) create mode 100644 src/mono/browser/build/BrowserWasmApp.CoreCLR.targets diff --git a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets new file mode 100644 index 00000000000000..f30db447d87201 --- /dev/null +++ b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/mono/browser/build/WasmApp.InTree.targets b/src/mono/browser/build/WasmApp.InTree.targets index 75e6db2903874d..ab86fb1780ecc7 100644 --- a/src/mono/browser/build/WasmApp.InTree.targets +++ b/src/mono/browser/build/WasmApp.InTree.targets @@ -8,6 +8,7 @@ + From ff67465eafc4f2280b2d49c427a9cf4d8cda4df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 12 Dec 2025 13:42:48 +0100 Subject: [PATCH 08/30] Append .dll extention to mainAssemblyName --- src/native/corehost/browserhost/host/host.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/native/corehost/browserhost/host/host.ts b/src/native/corehost/browserhost/host/host.ts index 689f960ba903e5..9cad2530bda27c 100644 --- a/src/native/corehost/browserhost/host/host.ts +++ b/src/native/corehost/browserhost/host/host.ts @@ -105,6 +105,10 @@ export async function runMain(mainAssemblyName?: string, args?: string[]): Promi if (!mainAssemblyName) { mainAssemblyName = config.mainAssemblyName!; } + // TODO-WASM: Difference in boot config generator + if (!mainAssemblyName.endsWith(".dll")) { + mainAssemblyName += ".dll"; + } const mainAssemblyNamePtr = dotnetBrowserUtilsExports.stringToUTF8Ptr(mainAssemblyName) as any; if (!args) { From 8212ed6cfdc467c1f602c630f694766164a0cb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 12 Dec 2025 15:02:46 +0100 Subject: [PATCH 09/30] Copy test runners --- eng/testing/tests.browser.targets | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/eng/testing/tests.browser.targets b/eng/testing/tests.browser.targets index 5e88f3b4922cbd..e6cd8379a02845 100644 --- a/eng/testing/tests.browser.targets +++ b/eng/testing/tests.browser.targets @@ -20,6 +20,10 @@ ReadWasmNativeAssetsFromFileSystem; UpdateWasmNativeAssetOriginalItemSpec + + $(ResolveWasmOutputsDependsOn); + AddTestRunnersToReferenceCopyLocalPaths + $([MSBuild]::NormalizeDirectory($(BrowserProjectRoot), 'emsdk')) @@ -176,6 +180,24 @@ + + + <_runnerFilesToBuild Include="$(WasmTestRunnerDir)*" /> + + + <_resolvedFilesToBuildToFileName Include="@(ReferenceCopyLocalPaths -> '%(FileName)%(Extension)')" /> + + <_runnerFilesToBuildToFileName Include="@(_runnerFilesToBuild -> '%(FileName)%(Extension)')"> + %(Identity) + + <_runnerFilesToBuildToFileName Remove="@(_resolvedFilesToBuildToFileName)" /> + + + + + From 55f90fba77476b9714d5cfc72bcb0917dff436c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Mon, 15 Dec 2025 15:22:20 +0100 Subject: [PATCH 10/30] Wasm.Build.Tests SDK --- eng/testing/workloads-browser.targets | 26 ++++++++++++++++++-------- eng/testing/workloads-wasm.targets | 3 ++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/eng/testing/workloads-browser.targets b/eng/testing/workloads-browser.targets index 4bb3ddb7502fdf..41b4ae6dd37959 100644 --- a/eng/testing/workloads-browser.targets +++ b/eng/testing/workloads-browser.targets @@ -8,7 +8,7 @@ - + - + <_RuntimePackNugetAvailable Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.$(RIDForWorkload).*$(PackageVersionForWorkloadManifests).nupkg" /> <_RuntimePackNugetAvailable Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.*.$(RIDForWorkload).*$(PackageVersionForWorkloadManifests).nupkg" /> <_RuntimePackNugetAvailable Remove="@(_RuntimePackNugetAvailable)" Condition="$([System.String]::new('%(_RuntimePackNugetAvailable.FileName)').EndsWith('.symbols'))" /> - - - - - + + + <_RuntimePackNugetAvailable Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.$(RIDForWorkload).*$(PackageVersionForWorkloadManifests).nupkg" /> + <_RuntimePackNugetAvailable Remove="@(_RuntimePackNugetAvailable)" Condition="$([System.String]::new('%(_RuntimePackNugetAvailable.FileName)').EndsWith('.symbols'))" /> + + + + + + + Descriptor="AOT Cross compiler" + Condition="'$(RuntimeFlavor)' == 'Mono'" /> From 63af39efca3bbe633cfd354df07639f14597f467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 16 Dec 2025 13:42:53 +0100 Subject: [PATCH 11/30] Skip InstallWorkloadFromArtifacts if no workloads selected --- .../Sdk/WorkloadTesting.Core.targets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/nuget/Microsoft.NET.Runtime.WorkloadTesting.Internal/Sdk/WorkloadTesting.Core.targets b/src/mono/nuget/Microsoft.NET.Runtime.WorkloadTesting.Internal/Sdk/WorkloadTesting.Core.targets index 550672aa417d8a..aa817442bf6cd9 100755 --- a/src/mono/nuget/Microsoft.NET.Runtime.WorkloadTesting.Internal/Sdk/WorkloadTesting.Core.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.WorkloadTesting.Internal/Sdk/WorkloadTesting.Core.targets @@ -197,6 +197,7 @@ + From 2a736b129ba03fb2a44340f785efdc5716e4879c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 16 Dec 2025 15:12:55 +0100 Subject: [PATCH 12/30] WBT running main --- .../BrowserStructures/TestAsset.cs | 1 + .../Common/BuildEnvironment.cs | 2 +- .../Common/EnvironmentVariables.cs | 1 + .../Templates/WasmTemplateTestsBase.cs | 20 ++++++++++++++ .../Wasm.Build.Tests/Wasm.Build.Tests.csproj | 6 +++++ .../WasmBrowserRunMainOnly.cs | 27 +++++++++++++++++++ .../data/RunScriptTemplate.cmd | 3 +++ .../data/RunScriptTemplate.sh | 4 +++ .../WasmBrowserRunMainOnly/Program.cs | 7 +++++ .../Properties/AssemblyInfo.cs | 4 +++ .../WasmBrowserRunMainOnly/TestOutput.cs | 18 +++++++++++++ .../WasmBrowserRunMainOnly.csproj | 11 ++++++++ .../WasmBrowserRunMainOnly/wwwroot/index.html | 18 +++++++++++++ .../WasmBrowserRunMainOnly/wwwroot/main.js | 14 ++++++++++ 14 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs create mode 100644 src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs create mode 100644 src/mono/wasm/testassets/WasmBrowserRunMainOnly/Properties/AssemblyInfo.cs create mode 100644 src/mono/wasm/testassets/WasmBrowserRunMainOnly/TestOutput.cs create mode 100644 src/mono/wasm/testassets/WasmBrowserRunMainOnly/WasmBrowserRunMainOnly.csproj create mode 100644 src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/index.html create mode 100644 src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.js diff --git a/src/mono/wasm/Wasm.Build.Tests/BrowserStructures/TestAsset.cs b/src/mono/wasm/Wasm.Build.Tests/BrowserStructures/TestAsset.cs index 83bf2e674d1a39..e4b4ec9efd0575 100644 --- a/src/mono/wasm/Wasm.Build.Tests/BrowserStructures/TestAsset.cs +++ b/src/mono/wasm/Wasm.Build.Tests/BrowserStructures/TestAsset.cs @@ -6,4 +6,5 @@ public class TestAsset public static readonly TestAsset BlazorBasicTestApp = new() { Name = "BlazorBasicTestApp", RunnableProjectSubPath = "App" }; public static readonly TestAsset LibraryModeTestApp = new() { Name = "LibraryMode" }; public static readonly TestAsset BlazorWebWasm = new() { Name = "BlazorWebWasm", RunnableProjectSubPath = "BlazorWebWasm" }; + public static readonly TestAsset WasmBrowserRunMainOnly = new() { Name = "WasmBrowserRunMainOnly" }; } diff --git a/src/mono/wasm/Wasm.Build.Tests/Common/BuildEnvironment.cs b/src/mono/wasm/Wasm.Build.Tests/Common/BuildEnvironment.cs index 753bcea4288a2f..e4f19301db4bca 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Common/BuildEnvironment.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Common/BuildEnvironment.cs @@ -111,7 +111,7 @@ public BuildEnvironment() $" {nameof(IsRunningOnCI)} is true but {nameof(IsWorkloadWithMultiThreadingForDefaultFramework)} is false."); } - UseWebcil = EnvironmentVariables.UseWebcil; + UseWebcil = EnvironmentVariables.UseWebcil && EnvironmentVariables.RuntimeFlavor != "CoreCLR"; // TODO-WASM: CoreCLR support for Webcil if (EnvironmentVariables.BuiltNuGetsPath is null || !Directory.Exists(EnvironmentVariables.BuiltNuGetsPath)) throw new Exception($"Cannot find 'BUILT_NUGETS_PATH={EnvironmentVariables.BuiltNuGetsPath}'"); diff --git a/src/mono/wasm/Wasm.Build.Tests/Common/EnvironmentVariables.cs b/src/mono/wasm/Wasm.Build.Tests/Common/EnvironmentVariables.cs index c1a932aed44b92..fb12b0830c7a0f 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Common/EnvironmentVariables.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Common/EnvironmentVariables.cs @@ -27,5 +27,6 @@ internal static class EnvironmentVariables internal static readonly string? SdkDirName = Environment.GetEnvironmentVariable("SDK_DIR_NAME"); internal static readonly string? WasiSdkPath = Environment.GetEnvironmentVariable("WASI_SDK_PATH"); internal static readonly bool WorkloadsTestPreviousVersions = Environment.GetEnvironmentVariable("WORKLOADS_TEST_PREVIOUS_VERSIONS") is "true"; + internal static readonly string? RuntimeFlavor = Environment.GetEnvironmentVariable("RUNTIME_FLAVOR_FOR_TESTS"); } } diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs index 31b38d420d405a..95ccbc470df12c 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs @@ -124,6 +124,26 @@ protected ProjectInfo CopyTestAsset( """; } + if (EnvironmentVariables.RuntimeFlavor == "CoreCLR") + { + // TODO-WASM: https://github.com/dotnet/sdk/issues/51213 + string versionSuffix = s_buildEnv.IsRunningOnCI ? "ci" : "dev"; + + extraProperties += + """ + false + """; + extraItems += + $$""" + + 11.0.0-{{versionSuffix}} + 11.0.0-{{versionSuffix}} + 11.0.0-{{versionSuffix}} + browser-wasm;%(RuntimePackRuntimeIdentifiers) + + """; + } + UpdateProjectFile(projectFilePath, runAnalyzers, extraProperties, extraItems, insertAtEnd); return new ProjectInfo(asset.Name, projectFilePath, logPath, nugetDir); } diff --git a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj index 812ad3661831bd..82cee846e987e7 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj +++ b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj @@ -74,6 +74,11 @@ + + + + + @@ -97,6 +102,7 @@ <_XUnitTraitArg Condition="'$(TestUsingWorkloads)' != 'true'">-trait category=no-workload <_XUnitTraitArg Condition="'$(WasmFingerprintAssets)' == 'false'">-trait category=no-fingerprinting <_XUnitTraitArg Condition="'$(WasmBundlerFriendlyBootConfig)' == 'true'">-trait category=bundler-friendly + <_XUnitTraitArg Condition="'$(RuntimeFlavor)' == 'CoreCLR'">-trait category=$(RuntimeFlavor) diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs b/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs new file mode 100644 index 00000000000000..3d817c3cd245f5 --- /dev/null +++ b/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs @@ -0,0 +1,27 @@ +using System.Collections.Specialized; +using System.Threading.Tasks; +using Xunit; +using Xunit.Abstractions; + +namespace Wasm.Build.Tests; + +public class WasmBrowserRunMainOnly(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) : WasmTemplateTestsBase(output, buildContext) +{ + [Fact, TestCategory("coreclr")] + public async Task RunMainOnly() + { + Configuration config = Configuration.Debug; + + ProjectInfo info = CopyTestAsset(config, false, TestAsset.WasmBrowserRunMainOnly, $"WasmBrowserRunMainOnly"); + PublishProject(info, config); + + var result = await RunForPublishWithWebServer(new BrowserRunOptions( + Configuration: config + )); + + Assert.Collection( + result.TestOutput, + m => Assert.Equal("Hello from WasmBrowserRunMainOnly!", m) + ); + } +} diff --git a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd index 608b2c6c1ea37e..0fe961d7e8199e 100644 --- a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd +++ b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd @@ -66,6 +66,9 @@ if [%WASM_BUNDLER_FRIENDLY_BOOT_CONFIG%] == [true] ( ) else ( set USE_JAVASCRIPT_BUNDLER_FOR_TESTS=false ) +if [%RUNTIME_FLAVOR%] NEQ [] ( + set RUNTIME_FLAVOR_FOR_TESTS=%RUNTIME_FLAVOR% +) if [%HELIX_CORRELATION_PAYLOAD%] NEQ [] ( robocopy /mt /np /nfl /NDL /nc /e %BASE_DIR%\%SDK_DIR_NAME% %EXECUTION_DIR%\%SDK_DIR_NAME% diff --git a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh index cee1769b006639..9cac0dd1442ed3 100644 --- a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh +++ b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh @@ -51,6 +51,10 @@ function set_env_vars() export USE_JAVASCRIPT_BUNDLER_FOR_TESTS=false fi + if [[ -n "$RUNTIME_FLAVOR" ]]; then + export RUNTIME_FLAVOR_FOR_TESTS=$RUNTIME_FLAVOR + fi + local _SDK_DIR= if [[ -n "$HELIX_WORKITEM_UPLOAD_ROOT" ]]; then cp -r $BASE_DIR/$SDK_DIR_NAME $EXECUTION_DIR diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs new file mode 100644 index 00000000000000..6041aa41421b8f --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs @@ -0,0 +1,7 @@ +using System; + +TestOutput.WriteLine("Hello from WasmBrowserRunMainOnly!"); + +// TODO-WASM: CoreCLR currently doesn't exit from Main +Console.WriteLine("WASM EXIT 0"); +return 0; \ No newline at end of file diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Properties/AssemblyInfo.cs b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000000..9ad9b578f20649 --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +[assembly:System.Runtime.Versioning.SupportedOSPlatform("browser")] diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/TestOutput.cs b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/TestOutput.cs new file mode 100644 index 00000000000000..5755b753b5e492 --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/TestOutput.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; + +public static class TestOutput +{ + public static void WriteLine(string message) + { + Console.WriteLine("TestOutput -> " + message); + } + + public static void WriteLine(object message) + { + Console.Write("TestOutput -> "); + Console.WriteLine(message); + } +} diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/WasmBrowserRunMainOnly.csproj b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/WasmBrowserRunMainOnly.csproj new file mode 100644 index 00000000000000..9951d602d915af --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/WasmBrowserRunMainOnly.csproj @@ -0,0 +1,11 @@ + + + net11.0 + true + true + + + + + + diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/index.html b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/index.html new file mode 100644 index 00000000000000..41fdfc8a46fd1d --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/index.html @@ -0,0 +1,18 @@ + + + + + + + WasmBrowserRunMainOnly + + + + + + + + + + + diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.js b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.js new file mode 100644 index 00000000000000..f30a0c34caff55 --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.js @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { dotnet } from './_framework/dotnet.js' + +await dotnet.create(); + +try { + await dotnet.run(); + console.log("WASM EXIT 0"); +} catch (err) { + console.error(err); + console.log("WASM EXIT 1"); +} \ No newline at end of file From a7ee811279a14f63a1fd5d02676dafc92db9acd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 16 Dec 2025 18:00:40 +0100 Subject: [PATCH 13/30] Prepare for skipping files from coreclr runtime pack --- .../AssetsComputingHelper.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs index c5869e14ed77bd..0dbe5e23f6a3c3 100644 --- a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs +++ b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs @@ -18,6 +18,12 @@ public class AssetsComputingHelper "Microsoft.NETCore.App.Runtime.Mono.multithread.browser-wasm", }; + private static readonly string[] coreclrPackageIds = new[] + { + "Microsoft.NETCore.App.Runtime.browser-wasm", + "Microsoft.NETCore.App.Runtime.multithread.browser-wasm", + }; + private static readonly string[] dotnetJsSingleThreadNames = new[] { "dotnet", @@ -52,7 +58,7 @@ public static bool ShouldFilterCandidate( var extension = candidate.GetMetadata("Extension"); var fileName = candidate.GetMetadata("FileName"); var assetType = candidate.GetMetadata("AssetType"); - bool fromMonoPackage = IsFromMonoPackage(candidate); + bool fromMonoPackage = IsFromRuntimePack(candidate); // A similar logic is in ReadWasmNativeAssetsFromFileSystem target for RuntimeTests reason = extension switch @@ -96,10 +102,10 @@ bool IsDefaultIcuMode() => string.IsNullOrEmpty(customIcuCandidateFilename); } - private static bool IsFromMonoPackage(ITaskItem candidate) + private static bool IsFromRuntimePack(ITaskItem candidate) { string packageId = candidate.GetMetadata("NuGetPackageId"); - return monoPackageIds.Contains(packageId, StringComparer.Ordinal); + return monoPackageIds.Contains(packageId, StringComparer.Ordinal) || coreclrPackageIds.Contains(packageId, StringComparer.Ordinal); } public static string GetCandidateRelativePath(ITaskItem candidate, bool fingerprintAssets, bool fingerprintDotNetJs) From 84b8780636fe53f7dd4a23bb4b62519fd66ea668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 16 Dec 2025 22:20:30 +0100 Subject: [PATCH 14/30] Pass DefaultTargetFramework to running browser --- .../WasmSdkBasedProjectProvider.cs | 15 ++++++++------- .../testassets/WasmBrowserRunMainOnly/Program.cs | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs index 487b08a6a56db6..93cb9af858aa01 100644 --- a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs +++ b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs @@ -15,11 +15,12 @@ namespace Wasm.Build.Tests; public class WasmSdkBasedProjectProvider : ProjectProviderBase { - private readonly string _defaultTargetFramework; + public string DefaultTargetFramework { get; } + public WasmSdkBasedProjectProvider(ITestOutputHelper _testOutput, string defaultTargetFramework, string? _projectDir = null) : base(_testOutput, _projectDir) { - _defaultTargetFramework = defaultTargetFramework; + DefaultTargetFramework = defaultTargetFramework; } protected override string BundleDirName { get { return "wwwroot"; } } @@ -96,7 +97,7 @@ public NativeFilesType GetExpectedFileType(Configuration config, bool isAOT, boo public void AssertBundle(Configuration config, MSBuildOptions buildOptions, bool isUsingWorkloads, bool? isNativeBuild = null, bool? wasmFingerprintDotnetJs = null) { string frameworkDir = string.IsNullOrEmpty(buildOptions.NonDefaultFrameworkDir) ? - GetBinFrameworkDir(config, buildOptions.IsPublish, _defaultTargetFramework) : + GetBinFrameworkDir(config, buildOptions.IsPublish, DefaultTargetFramework) : buildOptions.NonDefaultFrameworkDir; AssertBundle(new AssertBundleOptions( @@ -181,7 +182,7 @@ public void AssertWasmSdkBundle(Configuration config, MSBuildOptions buildOption if (isUsingWorkloads && buildOutput is not null) { // In no-workload case, the path would be from a restored nuget - ProjectProviderBase.AssertRuntimePackPath(buildOutput, buildOptions.TargetFramework ?? _defaultTargetFramework, buildOptions.RuntimeType); + ProjectProviderBase.AssertRuntimePackPath(buildOutput, buildOptions.TargetFramework ?? DefaultTargetFramework, buildOptions.RuntimeType); } AssertBundle(config, buildOptions, isUsingWorkloads, isNativeBuild, wasmFingerprintDotnetJs); } @@ -191,9 +192,9 @@ public BuildPaths GetBuildPaths(Configuration configuration, bool forPublish, st projectDir ??= ProjectDir!; Assert.NotNull(projectDir); string configStr = configuration.ToString(); - string objDir = Path.Combine(projectDir, "obj", configStr, _defaultTargetFramework); - string binDir = Path.Combine(projectDir, "bin", configStr, _defaultTargetFramework); - string binFrameworkDir = GetBinFrameworkDir(configuration, forPublish, _defaultTargetFramework); + string objDir = Path.Combine(projectDir, "obj", configStr, DefaultTargetFramework); + string binDir = Path.Combine(projectDir, "bin", configStr, DefaultTargetFramework); + string binFrameworkDir = GetBinFrameworkDir(configuration, forPublish, DefaultTargetFramework); string objWasmDir = Path.Combine(objDir, "wasm", forPublish ? "for-publish" : "for-build"); // for build: we should take from runtime pack? diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs index 6041aa41421b8f..2510b3f903e67f 100644 --- a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs @@ -1,7 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + using System; TestOutput.WriteLine("Hello from WasmBrowserRunMainOnly!"); // TODO-WASM: CoreCLR currently doesn't exit from Main Console.WriteLine("WASM EXIT 0"); -return 0; \ No newline at end of file +return 0; From 51177840fa598b94818aa4f7ad4d6ee484b3b994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 16 Dec 2025 22:23:24 +0100 Subject: [PATCH 15/30] Default to TestUsingWorkloads=false when RuntimeFlavor=CoreCLR --- src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj index 82cee846e987e7..478c530b217ec7 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj +++ b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj @@ -11,6 +11,7 @@ false + false true false From 54bc98fae780e191b5a1f421b25df619fc299a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 16 Dec 2025 22:29:27 +0100 Subject: [PATCH 16/30] Publish build artifacts --- eng/pipelines/runtime.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index fb7a47c2d9e2da..3e16e9783998fd 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -118,6 +118,10 @@ extends: - template: /eng/pipelines/common/templates/runtimes/build-runtime-tests.yml parameters: testBuildArgs: test JIT/interpreter/Interpreter.csproj + - template: /eng/pipelines/common/wasm-post-build-steps.yml + parameters: + publishArtifactsForWorkload: true + publishWBT: true extraVariablesTemplates: - template: /eng/pipelines/common/templates/runtimes/test-variables.yml parameters: From 03d4bcdfb8aa8c595401bc118bafa53f5db69d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 11:17:30 +0100 Subject: [PATCH 17/30] Include SDK related packages in coreclr-packages.proj --- src/coreclr/.nuget/coreclr-packages.proj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/coreclr/.nuget/coreclr-packages.proj b/src/coreclr/.nuget/coreclr-packages.proj index 609e6884946c88..afb25f65144032 100644 --- a/src/coreclr/.nuget/coreclr-packages.proj +++ b/src/coreclr/.nuget/coreclr-packages.proj @@ -12,5 +12,13 @@ + + + + + + + + From e4baffacca580a2afe38253536717848a50969c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 11:35:39 +0100 Subject: [PATCH 18/30] Build Wasm.Build.Tests on CI for CoreCLR --- .../browser-wasm-coreclr-build-tests.yml | 128 ++++++++++++++++++ eng/pipelines/runtime.yml | 11 +- 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml diff --git a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml new file mode 100644 index 00000000000000..ee76123159181d --- /dev/null +++ b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml @@ -0,0 +1,128 @@ +# Depends on other builds to get runtime packs, and nugets +# And then runs Wasm.Build.Tests +parameters: + alwaysRun: false + isExtraPlatformsBuild: false + isWasmOnlyBuild: false + platforms: [] + shouldContinueOnError: false + extraBuildArgs: '' + +jobs: + +- ${{ each platform in parameters.platforms }}: + - template: /eng/pipelines/common/platform-matrix.yml + parameters: + jobTemplate: /eng/pipelines/common/global-build-job.yml + helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml + buildConfig: Release + runtimeFlavor: mono + platforms: + - ${{ platform }} + shouldContinueOnError: ${{ parameters.shouldContinueOnError }} + variables: + # map dependencies variables to local variables + - name: alwaysRunVar + value: ${{ parameters.alwaysRun }} + - name: workloadsTestPreviousVersionsVar + value: false +# value: $[ +# or( +# eq(variables['Build.SourceBranchName'], 'main'), +# eq(variables['System.PullRequest.TargetBranch'], 'main')) +# ] + - name: wbtProjectArg + ${{ if eq(platform, 'browser_wasm_win') }}: + value: '-projects' + ${{ else }}: + value: '--projects' + - name: shouldRunOnDefaultPipelines + value: $(shouldRunWasmBuildTestsOnDefaultPipeline) + + jobParameters: + dependsOn: + - ${{ if eq(platform, 'browser_wasm') }}: + - build_browser_wasm_linux_Debug_AllSubsets_CoreCLR + - ${{ if eq(platform, 'browser_wasm_win') }}: + - build_browser_wasm_windows_Debug_AllSubsets_CoreCLR + isExtraPlatforms: ${{ parameters.isExtraPlatformsBuild }} + testGroup: innerloop + nameSuffix: WasmBuildTests + + preBuildSteps: + # Download single threaded runtime packs, and tasks needed to build WBT + - task: DownloadBuildArtifacts@0 + displayName: Download built nugets for singlethreaded runtime + inputs: + buildType: current + artifactName: 'BuildArtifacts_browser_wasm_$(_hostedOs)_Debug_AllSubsets_CoreCLR' + downloadType: single + downloadPath: '$(Build.SourcesDirectory)/artifacts' + + - task: CopyFiles@2 + displayName: Copy single threaded assets + inputs: + SourceFolder: '$(Build.SourcesDirectory)/artifacts/BuildArtifacts_browser_wasm_$(_hostedOs)_Debug_AllSubsets_CoreCLR' + TargetFolder: '$(Build.SourcesDirectory)/artifacts' + CleanTargetFolder: false + + # Download for multi-threaded + # - task: DownloadBuildArtifacts@0 + # displayName: Download built nugets for multi-threaded runtime + # inputs: + # buildType: current + # artifactName: BuildArtifacts_browser_wasm_$(_hostedOs)_Release_MultiThreaded_BuildOnly + # downloadType: single + # downloadPath: '$(Build.SourcesDirectory)/artifacts' + + # - task: CopyFiles@2 + # displayName: Copy multithreading runtime pack + # inputs: + # SourceFolder: '$(Build.SourcesDirectory)/artifacts/BuildArtifacts_browser_wasm_$(_hostedOs)_Release_MultiThreaded_BuildOnly' + # Contents: packages/$(_BuildConfig)/Shipping/Microsoft.NETCore.App.Runtime.Mono.multithread.* + # TargetFolder: '$(Build.SourcesDirectory)/artifacts' + # CleanTargetFolder: false + + # Download WBT - TODO-WASM: This points to "mono" build, altough + - task: DownloadBuildArtifacts@0 + displayName: Download Wasm.Build.Tests + inputs: + buildType: current + artifactName: WasmBuildTests_$(_hostedOs)_AllSubsets_CoreCLR + downloadType: single + downloadPath: '$(Build.SourcesDirectory)/artifacts' + + - task: CopyFiles@2 + displayName: Copy Wasm.Build.Tests archive + inputs: + SourceFolder: '$(Build.SourcesDirectory)/artifacts/WasmBuildTests_$(_hostedOs)_AllSubsets_CoreCLR' + Contents: helix/** + TargetFolder: '$(Build.SourcesDirectory)/artifacts' + CleanTargetFolder: false + + # build WBT + buildArgs: >- + $(wbtProjectArg) $(Build.SourcesDirectory)/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj + /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Build.binlog + /p:Configuration=$(_BuildConfig) + /p:TestUsingWorkloads=true + /p:InstallWorkloadForTesting=true + /p:WasmSkipMissingRuntimePackBuild=true + /p:PreparePackagesForWorkloadInstall=false + /p:WorkloadsTestPreviousVersions=$(workloadsTestPreviousVersionsVar) + /p:runtimeFlavor=CoreCLR + timeoutInMinutes: 180 + condition: >- + or( + eq(variables['alwaysRunVar'], true), + eq(variables['isDefaultPipeline'], variables['shouldRunWasmBuildTestsOnDefaultPipeline'])) + + # extra steps, run tests + postBuildSteps: + - template: /eng/pipelines/libraries/helix.yml + parameters: + creator: dotnet-bot + testRunNamePrefixSuffix: Mono_$(_BuildConfig)_$(_hostedOs) + extraHelixArguments: /p:BrowserHost=$(_hostedOs) + scenarios: + - buildwasmapps diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index 3e16e9783998fd..16a646ac1ac7e5 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -112,7 +112,7 @@ extends: - browser_wasm_win jobParameters: nameSuffix: AllSubsets_CoreCLR - buildArgs: -s clr+libs+packs -c $(_BuildConfig) -lc Release + buildArgs: -s clr+libs+libs.tests+packs -c $(_BuildConfig) -lc Release /p:TestAssemblies=false /p:TestWasmBuildTests=true /p:ArchiveTests=true /p:InstallWorkloadForTesting=false timeoutInMinutes: 120 postBuildSteps: - template: /eng/pipelines/common/templates/runtimes/build-runtime-tests.yml @@ -134,6 +134,15 @@ extends: eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_wasm_coreclr_runtimetests.containsChange'], true), eq(variables['isRollingBuild'], true)) + # Browser Wasm.Build.Tests + - template: /eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml + parameters: + platforms: + - browser_wasm + - browser_wasm_win + alwaysRun: ${{ variables.isRollingBuild }} + extraBuildArgs: /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + # # Build CoreCLR and Libraries with Libraries tests # For running libraries tests and installer tests From e2717cb199691d13c9fc4275d23fa7f00513f962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 13:08:18 +0100 Subject: [PATCH 19/30] Build Wasm.Build.Tests on CI for CoreCLR (unique name) --- .../common/templates/browser-wasm-coreclr-build-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml index ee76123159181d..cca9d196e07df6 100644 --- a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml +++ b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml @@ -47,7 +47,7 @@ jobs: - build_browser_wasm_windows_Debug_AllSubsets_CoreCLR isExtraPlatforms: ${{ parameters.isExtraPlatformsBuild }} testGroup: innerloop - nameSuffix: WasmBuildTests + nameSuffix: CoreCLR_WasmBuildTests preBuildSteps: # Download single threaded runtime packs, and tasks needed to build WBT From 1c0183767e176fb9fe7c5e0a21e275213b63acc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 13:47:57 +0100 Subject: [PATCH 20/30] Fix paths --- src/coreclr/.nuget/coreclr-packages.proj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/.nuget/coreclr-packages.proj b/src/coreclr/.nuget/coreclr-packages.proj index afb25f65144032..587ddf302627d0 100644 --- a/src/coreclr/.nuget/coreclr-packages.proj +++ b/src/coreclr/.nuget/coreclr-packages.proj @@ -13,11 +13,11 @@ - - - + + + - + From e9918f1d773f6bff6d0ac2c2008a9c890c00ec59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 15:30:12 +0100 Subject: [PATCH 21/30] Build Wasm.Build.Tests on CI for CoreCLR (configuration=debug) --- .../common/templates/browser-wasm-coreclr-build-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml index cca9d196e07df6..aea44053e630b9 100644 --- a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml +++ b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml @@ -15,7 +15,7 @@ jobs: parameters: jobTemplate: /eng/pipelines/common/global-build-job.yml helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml - buildConfig: Release + buildConfig: Debug runtimeFlavor: mono platforms: - ${{ platform }} From ecdf53e6ad03063d1f713c35840af9b8ef2483ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 17:16:23 +0100 Subject: [PATCH 22/30] Build Wasm.Build.Tests on CI for CoreCLR (TestUsingWorkloads=false) --- .../common/templates/browser-wasm-coreclr-build-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml index aea44053e630b9..2b921134da7b8a 100644 --- a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml +++ b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml @@ -105,7 +105,7 @@ jobs: $(wbtProjectArg) $(Build.SourcesDirectory)/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Build.binlog /p:Configuration=$(_BuildConfig) - /p:TestUsingWorkloads=true + /p:TestUsingWorkloads=false /p:InstallWorkloadForTesting=true /p:WasmSkipMissingRuntimePackBuild=true /p:PreparePackagesForWorkloadInstall=false From 5bbf891f4e041f4eb0ba18e97c7d48cd422bce2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 17:19:08 +0100 Subject: [PATCH 23/30] Typo --- .../common/templates/browser-wasm-coreclr-build-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml index 2b921134da7b8a..a8316361942d11 100644 --- a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml +++ b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml @@ -110,7 +110,7 @@ jobs: /p:WasmSkipMissingRuntimePackBuild=true /p:PreparePackagesForWorkloadInstall=false /p:WorkloadsTestPreviousVersions=$(workloadsTestPreviousVersionsVar) - /p:runtimeFlavor=CoreCLR + /p:RuntimeFlavor=CoreCLR timeoutInMinutes: 180 condition: >- or( From 4e6dfa6c79ff7a6fc65caaca087ce1f54ec17c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 18 Dec 2025 10:23:49 +0100 Subject: [PATCH 24/30] Fix RuntimeFlavor for build. Apply -trait CoreCLR. Reduce Scenarios for CoreCLR --- .../templates/browser-wasm-coreclr-build-tests.yml | 2 +- src/libraries/sendtohelix-browser.targets | 1 + src/libraries/sendtohelix.proj | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml index a8316361942d11..55c268d6ee2484 100644 --- a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml +++ b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml @@ -16,7 +16,7 @@ jobs: jobTemplate: /eng/pipelines/common/global-build-job.yml helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml buildConfig: Debug - runtimeFlavor: mono + runtimeFlavor: CoreCLR platforms: - ${{ platform }} shouldContinueOnError: ${{ parameters.shouldContinueOnError }} diff --git a/src/libraries/sendtohelix-browser.targets b/src/libraries/sendtohelix-browser.targets index 7c37ece047371f..7c481e1950e2c5 100644 --- a/src/libraries/sendtohelix-browser.targets +++ b/src/libraries/sendtohelix-browser.targets @@ -135,6 +135,7 @@ <_XUnitTraitArg Condition="'$(TestUsingWorkloads)' != 'true'">-trait category=no-workload <_XUnitTraitArg Condition="'$(WasmFingerprintAssets)' == 'false'">$(_XUnitTraitArg) -trait category=no-fingerprinting <_XUnitTraitArg Condition="'$(WasmBundlerFriendlyBootConfig)' == 'true'">$(_XUnitTraitArg) -trait category=bundler-friendly + <_XUnitTraitArg Condition="'$(RuntimeFlavor)' == 'CoreCLR'">-trait category=$(RuntimeFlavor) diff --git a/src/libraries/sendtohelix.proj b/src/libraries/sendtohelix.proj index c121c3c009d51b..36d808959c53a8 100644 --- a/src/libraries/sendtohelix.proj +++ b/src/libraries/sendtohelix.proj @@ -85,10 +85,11 @@ - <_TestUsingWorkloadsValues Include="true;false" /> - <_TestUsingWebcilValues Include="true;false" Condition="'$(TargetOS)' == 'browser'" /> - <_TestUsingFingerprintingValues Include="true;false" Condition="'$(TargetOS)' == 'browser'" /> - <_TestUsingJavascriptBundlerValues Include="true;false" Condition="'$(TargetOS)' == 'browser'" /> + <_TestUsingWorkloadsValues Include="false" /> + <_TestUsingWorkloadsValues Include="true" Condition="'$(RuntimeFlavor)' == 'Mono'" /> + <_TestUsingWebcilValues Include="true;false" Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'Mono'" /> + <_TestUsingFingerprintingValues Include="true;false" Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'Mono'" /> + <_TestUsingJavascriptBundlerValues Include="true;false" Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'Mono'" /> <_TestUsingCrossProductValuesTemp Include="@(_TestUsingWorkloadsValues)"> From 7a539452a4595e9c25dc6eed8f9046fe10ea0619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 18 Dec 2025 10:28:21 +0100 Subject: [PATCH 25/30] RuntimeFlavor for WBT on Mono --- eng/pipelines/common/templates/browser-wasm-build-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/pipelines/common/templates/browser-wasm-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-build-tests.yml index 0963ebed5a5350..39fca50137411f 100644 --- a/eng/pipelines/common/templates/browser-wasm-build-tests.yml +++ b/eng/pipelines/common/templates/browser-wasm-build-tests.yml @@ -112,6 +112,7 @@ jobs: /p:WasmSkipMissingRuntimePackBuild=true /p:PreparePackagesForWorkloadInstall=false /p:WorkloadsTestPreviousVersions=$(workloadsTestPreviousVersionsVar) + /p:RuntimeFlavor=Mono timeoutInMinutes: 180 condition: >- or( From 83298236f1d5f5f8deaf1d8747c466dcceb6665e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 18 Dec 2025 12:00:29 +0100 Subject: [PATCH 26/30] BundlerFriendly WBT only on Mono --- src/libraries/sendtohelix.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/sendtohelix.proj b/src/libraries/sendtohelix.proj index 36d808959c53a8..2f298dbd7f3d79 100644 --- a/src/libraries/sendtohelix.proj +++ b/src/libraries/sendtohelix.proj @@ -107,7 +107,7 @@ <_TestUsingCrossProductValues Remove="@(_TestUsingCrossProductValues)" Condition="'%(_TestUsingCrossProductValues.Workloads)' == 'false' and '%(_TestUsingCrossProductValues.Fingerprinting)' == 'false'" /> - <_TestUsingCrossProductValues Include="JavaScriptBundlerFriendly"> + <_TestUsingCrossProductValues Include="JavaScriptBundlerFriendly" Condition="'$(RuntimeFlavor)' == 'Mono'"> true true true From ed443f1bc51219c34ad692fb6a5dbc52d9ee5906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 18 Dec 2025 12:10:12 +0100 Subject: [PATCH 27/30] RuntimeFlavor=Mono for linker-tests --- eng/pipelines/runtime-linker-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/runtime-linker-tests.yml b/eng/pipelines/runtime-linker-tests.yml index 3f2e6c1da8b5d1..e5fe67fbc0b595 100644 --- a/eng/pipelines/runtime-linker-tests.yml +++ b/eng/pipelines/runtime-linker-tests.yml @@ -135,5 +135,5 @@ extends: postBuildSteps: - template: /eng/pipelines/libraries/execute-trimming-tests-steps.yml parameters: - extraTestArgs: '/p:WasmBuildNative=false' + extraTestArgs: '/p:WasmBuildNative=false /p:RuntimeFlavor=Mono' runAotTests: false From 22c1723cc93599cf4733fd62f2abdb102f233f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 18 Dec 2025 13:26:15 +0100 Subject: [PATCH 28/30] testRunNamePrefixSuffix for CoreCLR --- .../common/templates/browser-wasm-coreclr-build-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml index 55c268d6ee2484..aa776908d79d07 100644 --- a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml +++ b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml @@ -122,7 +122,7 @@ jobs: - template: /eng/pipelines/libraries/helix.yml parameters: creator: dotnet-bot - testRunNamePrefixSuffix: Mono_$(_BuildConfig)_$(_hostedOs) + testRunNamePrefixSuffix: CoreCLR_$(_BuildConfig)_$(_hostedOs) extraHelixArguments: /p:BrowserHost=$(_hostedOs) scenarios: - buildwasmapps From db6086ee4ce5d2c958a7b8bf2803bac99aca29e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 18 Dec 2025 15:29:16 +0100 Subject: [PATCH 29/30] Update eng/testing/tests.browser.targets Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- eng/testing/tests.browser.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/testing/tests.browser.targets b/eng/testing/tests.browser.targets index e6cd8379a02845..d7426f7d4339a4 100644 --- a/eng/testing/tests.browser.targets +++ b/eng/testing/tests.browser.targets @@ -186,7 +186,7 @@ <_runnerFilesToBuild Include="$(WasmTestRunnerDir)*" /> - + <_resolvedFilesToBuildToFileName Include="@(ReferenceCopyLocalPaths -> '%(FileName)%(Extension)')" /> <_runnerFilesToBuildToFileName Include="@(_runnerFilesToBuild -> '%(FileName)%(Extension)')"> From 59968bdd2be22ce697fcda6f8e792b06a3e3455d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 18 Dec 2025 19:58:04 +0100 Subject: [PATCH 30/30] Async main. Assert runtime pack name. Remove unused MSBuild value --- src/libraries/sendtohelix.proj | 1 - .../Wasm.Build.Tests/WasmBrowserRunMainOnly.cs | 5 ++++- .../testassets/WasmBrowserRunMainOnly/Program.cs | 15 +++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/libraries/sendtohelix.proj b/src/libraries/sendtohelix.proj index 2f298dbd7f3d79..4107809be25b7c 100644 --- a/src/libraries/sendtohelix.proj +++ b/src/libraries/sendtohelix.proj @@ -89,7 +89,6 @@ <_TestUsingWorkloadsValues Include="true" Condition="'$(RuntimeFlavor)' == 'Mono'" /> <_TestUsingWebcilValues Include="true;false" Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'Mono'" /> <_TestUsingFingerprintingValues Include="true;false" Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'Mono'" /> - <_TestUsingJavascriptBundlerValues Include="true;false" Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'Mono'" /> <_TestUsingCrossProductValuesTemp Include="@(_TestUsingWorkloadsValues)"> diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs b/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs index 3d817c3cd245f5..1670dbdc4aea9b 100644 --- a/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs +++ b/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs @@ -13,7 +13,10 @@ public async Task RunMainOnly() Configuration config = Configuration.Debug; ProjectInfo info = CopyTestAsset(config, false, TestAsset.WasmBrowserRunMainOnly, $"WasmBrowserRunMainOnly"); - PublishProject(info, config); + var (_, buildOutput) = PublishProject(info, config); + + // ** MicrosoftNetCoreAppRuntimePackDir : '....microsoft.netcore.app.runtime.browser-wasm\11.0.0-dev' + Assert.Contains("microsoft.netcore.app.runtime.browser-wasm", buildOutput); var result = await RunForPublishWithWebServer(new BrowserRunOptions( Configuration: config diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs index 2510b3f903e67f..4cc25e77dc7037 100644 --- a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs @@ -1,10 +1,13 @@ // 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.Threading.Tasks; -TestOutput.WriteLine("Hello from WasmBrowserRunMainOnly!"); - -// TODO-WASM: CoreCLR currently doesn't exit from Main -Console.WriteLine("WASM EXIT 0"); -return 0; +class Program +{ + static Task Main(string[] args) + { + TestOutput.WriteLine("Hello from WasmBrowserRunMainOnly!"); + return Task.FromResult(0); + } +} \ No newline at end of file