Skip to content

[browser][coreclr] Stage composite R2R image for library tests - #135897

Merged
lewing merged 3 commits into
mainfrom
lewing-browser-composite-library-tests
Oct 17, 2026
Merged

lewing merged 3 commits into
mainfrom
lewing-browser-composite-library-tests

Conversation

@lewing

@lewing lewing commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Browser CoreCLR library tests fail to start with PublishReadyToRunComposite=true:

DOTNET: Assembly not found: 'System.Memory.Tests.r2r.wasm'
Aborting startup

Cause

Library tests crossgen inside the nested publish, then serve the build output from bin/. The build-time webcil staging reads obj/R2R, so the composite component stubs are staged. The composite owner (<entry>.r2r.wasm) is not an assembly, though. The WebAssembly SDK defines it only as a publish static web asset in ProcessPublishFilesForWasm, which doesn't run here. As a result the owner is never copied to wwwroot/_framework and never listed in the build boot config.

Fix

The nested publish now returns the composite image as one of its outputs, the same way WasmNativeAsset and WasmAssembliesFinal flow back to the outer build:

  • BrowserWasmApp.CoreCLR.targets: WasmNestedPublishApp returns the image it produced (_ReadyToRunCompileList with CreateCompositeImage=true) as _WasmNestedPublishCompositeR2RImage, and WasmTriggerPublishApp collects it.
  • Microsoft.NET.Sdk.WebAssembly.Browser.targets: when that item is present, _ResolveWasmOutputs defines the image as a build static web asset with the existing WasmResource=readyToRunComposite trait. GenerateWasmBootJson then lists it in coreAssembly with isCompositeImage, and it is copied to output and fingerprinted like the other framework assets.

In a regular dotnet publish, the outer build resolves its assets before WasmTriggerPublishApp runs, so the item is empty there and the existing publish asset remains the only definition. eng/testing/tests.browser.targets is unchanged.

docs/workflow/testing/libraries/testing-wasm.md now documents the composite library-test command.

Validation (macOS arm64, Release)

Prereq: ./build.sh clr+libs+host+packs -os browser -c Release /p:AotHostArchitecture=arm64 /p:AotHostOS=osx

Library tests. Base command: ./build.sh libs.tests -test -os browser -c Release --projects <csproj> /p:RuntimeFlavor=CoreCLR /p:TestWasmReadyToRun=true /p:EnableAggressiveTrimming=true; composite runs add /p:PublishReadyToRunComposite=true.

Scenario Result
System.Memory.Tests, composite, clean 52254 run, 0 failed
Same, incremental rerun 52254 run, 0 failed
System.Memory.Tests, per-assembly, clean 52254 run, 0 failed (no composite image staged)
Per-assembly → composite without cleaning 52254 run, 0 failed
System.Runtime.Tests, composite, clean 78303 run, 0 failed

Apps:

  • Wasm.Build.Tests.ReadyToRunTests (CoreCLR, no-workload, rebuilt Microsoft.NET.Sdk.WebAssembly.Pack): 10/10 passed. These publishes don't run a nested publish, so this shows the new block is a no-op for them.
  • Composite publish of src/mono/sample/wasm/console-node (make publish MSBUILD_ARGS="/p:RuntimeFlavor=CoreCLR /p:PublishReadyToRun=true /p:PublishReadyToRunComposite=true", twice): runs under node with one composite image and one isCompositeImage entry. The binlog shows the outer _ResolveWasmOutputs runs before the nested publish returns the image.

Note

This PR description was generated with GitHub Copilot.

lewing and others added 2 commits October 15, 2026 15:55
Library tests crossgen in the nested publish but serve the build output from
bin/. The composite owner (<entry>.r2r.wasm) was only defined as a publish
static web asset, so it was never copied to bin/wwwroot/_framework or listed
in the build boot config, and startup aborted with "Assembly not found".

Define the owner as a build static web asset with the readyToRunComposite
trait in the test infrastructure so the build boot config lists it as a
composite image. Document the composite library test command.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 5cdca42a-e013-4c55-bdc9-491a5efb80a9
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 5cdca42a-e013-4c55-bdc9-491a5efb80a9
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@lewing lewing added area-Infrastructure-libraries arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm and removed area-Build-mono labels Oct 15, 2026
@lewing
lewing requested a review from maraf October 15, 2026 21:31
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Comment thread eng/testing/tests.browser.targets Resolved
Instead of globbing obj/R2R from test infrastructure, have WasmNestedPublishApp
return the composite ReadyToRun image it produced, and define it as a build
static web asset in _ResolveWasmOutputs when a nested publish ran during the
build. A regular publish resolves build assets before the nested publish runs,
so it keeps using the existing publish asset.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 5cdca42a-e013-4c55-bdc9-491a5efb80a9
@lewing
lewing merged commit ae00797 into main Oct 17, 2026
49 of 52 checks passed
@lewing
lewing deleted the lewing-browser-composite-library-tests branch October 17, 2026 19:02
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 19, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-Infrastructure-libraries os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants