Skip to content

Conversation

@maraf
Copy link
Member

@maraf maraf commented Dec 12, 2025

  • Connect in-tree CoreCLR artifacts with Wasm SDK
  • Disconnect mono native build from Wasm SDK if building for CoreCLR in-tree
  • Define in-tree defaults for CoreCLR
    • WasmEnableWebcil=false
    • InvariantGlobalization=false
    • EnableAggressiveTrimming=false
    • PublishTrimmed=false
  • Prepare an empty shim for CoreCLR native build
  • Copy native (JS, etc) assets to CoreCLR runtime pack
  • Build Wasm SDK packages as part of CoreCLR packages (coreclr-packages.proj)
  • Extend current browser-wasm CoreCLR Debug CI job to produce assets for Wasm.Build.Tests
  • Run Wasm.Build.Tests for CoreCLR with a simple "run main" tests
    • Using plain .NET SDK (dotnet-none) with overrides to use CoreCLR (/p:UseMonoRuntime=false) and points packages to those built from the repository
  • Copy test runners for CoreCLR libtests during build as we don't do nested publish
  • Extend properties pass to nested publish for in-tree sample with /t:RunSample
  • Add .dll if missing to config.mainAssemblyName before running it

Fixes #120647

Some issues discovered when running various tests

  • MainAssemblyName needs to end with .dll
  • Xharness with symbolicator fails
    • XHarness is .NET 9, but we are building plugins as .NET 10. The same problem is with RemoveLoopServer
  • WasmTestRunner is dependent on nested publish AddTestRunnersToPublishedFiles -> ComputeResolvedFilesToPublishList -> WasmTriggerPublishApp
  • Most of with*** function in test-main.js are undefined on CoreCLR - [browser][mono] simplify internal testing switches #122616
  • FileNotFoundException: Could not load file or assembly '/System.Console.Tests.dll'
    • It's Assembly.LoadFrom(TestAssembly). Mono knows "app" assemblies are loaded; CoreCLR requires to load them through VFS
  • Linker tests are missing RuntimeFlavor src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets(241,37): error MSB4057: (NETCORE_ENGINEERING_TELEMETRY=Build) The target "WasmTriggerPublishApp" does not exist in the project.

The runtime pack now contains all the necessary files
image

Errors

Xharness with symbolicator fails
  [11.0.0-prerelease.25603.1+3df2923500447ee925d59f026c81720c7a9b4e4b] XHarness command issued: wasm test-browser --app=. --output-directory=D:\Development\dotnet\runtime\artifacts\bin\System.Console.Tests\Debug\net11.0\browser-wasm\wwwroot\xharness-output -s dotnet.native.js.symbols --symbol-patterns wasm-symbol-patterns.txt --symbolicator WasmSymbolicator.dll,Microsoft.WebAssembly.Internal.SymbolicatorWrapperForXHarness --browser-path=D:\Development\dotnet\runtime\artifacts\bin\chrome\chrome-win\chrome.exe --timeout=00:30:00 --browser-arg=--js-flags=--stack-trace-limit=1000 --browser-arg=--disable-gpu --pageLoadStrategy=none -- --run WasmTestRunner.dll System.Console.Tests.dll -notrait category=OuterLoop -notrait category=failing
  crit: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
        Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
        Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
        Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
        Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
        Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
           at System.Reflection.RuntimeModule.GetDefinedTypes()
           at System.Reflection.RuntimeModule.GetTypes()
           at Microsoft.DotNet.XHarness.CLI.CommandArguments.TypeFromAssemblyArgument`1.GetLoadedTypes()+MoveNext() in /_/src/Microsoft.DotNet.XHarness.CLI/CommandArguments/Arguments/TypeFromAssemblyArgument.cs:line 29
           at System.Linq.Enumerable.TryGetFirstNonIterator[TSource](IEnumerable`1 source, Boolean& found)
           at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
           at Microsoft.DotNet.XHarness.CLI.Commands.Wasm.WasmTestBrowserCommand.InvokeInternal(ILogger logger) in /_/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs:line 48
           at Microsoft.DotNet.XHarness.CLI.Commands.XHarnessCommand`1.Invoke(IEnumerable`1 arguments) in /_/src/Microsoft.DotNet.XHarness.CLI/Commands/XHarnessCommand.cs:line 145
        System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
        File name: 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
        System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
        File name: 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
        System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
        File name: 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
        System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
        File name: 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
        System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
        File name: 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  XHarness exit code: 71 (GENERAL_FAILURE)
  ----- end 2025-12-12 13:48:03.71 ----- exit code 71 ----------------------------------------------------------
  XHarness artifacts: D:\Development\dotnet\runtime\artifacts\bin\System.Console.Tests\Debug\net11.0\browser-wasm\wwwroot\xharness-output
FileNotFoundException: Could not load file or assembly '/System.Console.Tests.dll' ``` dotnet.js:945 DOTNET: FileNotFoundException: Could not load file or assembly '/System.Console.Tests.dll'. The system cannot find the file specified.

at System.Runtime.Loader.AssemblyLoadContext.g____PInvoke|5_0(:63603/IntPtr __ptrNativeAssemblyBinder_native, UInt16* __ilPath_native, UInt16* __niPath_native, ObjectHandleOnStack __retAssembly_native)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(:63603/IntPtr ptrNativeAssemblyBinder, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.InternalLoadFromPath(:63603/String assemblyPath, String nativeImagePath)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(:63603/String assemblyPath)
at System.Reflection.Assembly.LoadFrom(:63603/String assemblyFile)
at Microsoft.DotNet.XHarness.TestRunners.Xunit.WasmApplicationEntryPoint.GetTestAssemblies(index.html?arg=--run&arg=WasmTestRunner.dll&arg=System.Console.Tests.dll&arg=-notrait&arg=category%…)
at Microsoft.DotNet.XHarness.TestRunners.Common.ApplicationEntryPoint.InternalRunAsync(:63603/LogWriter logger)
at Microsoft.DotNet.XHarness.TestRunners.Common.ApplicationEntryPoint.InternalRunAsync(:63603/ApplicationOptions options, TextWriter loggerWriter, TextWriter resultsFile)
at Microsoft.DotNet.XHarness.TestRunners.Common.WasmApplicationEntryPointBase.RunAsync(index.html?arg=--run&arg=WasmTestRunner.dll&arg=System.Console.Tests.dll&arg=-notrait&arg=category%…)
at Microsoft.DotNet.XHarness.TestRunners.Xunit.WasmApplicationEntryPoint.Run(index.html?arg=--run&arg=WasmTestRunner.dll&arg=System.Console.Tests.dll&arg=-notrait&arg=category%…)
at WasmTestRunner.MainAsync(:63603/String[] args)


</details>

@maraf maraf added this to the 11.0.0 milestone Dec 12, 2025
@maraf maraf self-assigned this Dec 12, 2025
@maraf maraf added arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm labels Dec 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables CoreCLR runtime support in the WebAssembly SDK infrastructure. Currently, the Wasm SDK was designed primarily for the Mono runtime, and this work adapts it to support building and testing WebAssembly applications with CoreCLR as well.

Key changes include:

  • Adding CoreCLR package identifiers to runtime pack detection logic
  • Creating CoreCLR-specific build targets and property defaults
  • Extending Wasm.Build.Tests to run with CoreCLR using plain .NET SDK with runtime override
  • Adding a simple test asset (WasmBrowserRunMainOnly) for CoreCLR validation

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs Adds CoreCLR package IDs to runtime pack detection
src/native/corehost/corehost.proj Copies native JS/Wasm assets to CoreCLR runtime pack
src/native/corehost/browserhost/host/host.ts Adds .dll extension to mainAssemblyName if missing
src/mono/wasm/testassets/WasmBrowserRunMainOnly/* New test asset for basic CoreCLR wasm testing
src/mono/wasm/Wasm.Build.Tests/* Extends test infrastructure to support CoreCLR execution
src/mono/browser/build/* Adds CoreCLR-specific build targets and property defaults
src/coreclr/.nuget/coreclr-packages.proj Includes Wasm SDK packages in CoreCLR package build
eng/testing/* Updates test configuration to conditionally run workload-based tests and add CoreCLR runtime pack references
eng/pipelines/* Adds CI job for CoreCLR Wasm.Build.Tests
Comments suppressed due to low confidence (1)

src/native/corehost/corehost.proj:1

  • Corrected spelling of 'altough' to 'although'.

@pavelsavara
Copy link
Member

Wasm.Build.Tests.WasmBrowserRunMainOnly.RunMainOnly 🎉

Log

[log] TestOutput -> Hello from WasmBrowserRunMainOnly!
Exited with 0
[log] WASM EXIT 0

@pavelsavara
Copy link
Member

/ba-g known issues
#113686
#112360
#122669
#122671

@pavelsavara pavelsavara merged commit 637d4b5 into dotnet:main Dec 19, 2025
170 of 177 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][coreclr] Bring WBT tests on coreclr, make a few non-workload WBT tests work

2 participants