Skip to content

[browser] Make WASM framework asset CopyToOutputDirectory configurable#127286

Merged
maraf merged 1 commit intodotnet:mainfrom
maraf:maraf/WasmSdkCopyToBin2
Apr 23, 2026
Merged

[browser] Make WASM framework asset CopyToOutputDirectory configurable#127286
maraf merged 1 commit intodotnet:mainfrom
maraf:maraf/WasmSdkCopyToBin2

Conversation

@maraf
Copy link
Copy Markdown
Member

@maraf maraf commented Apr 22, 2026

Note

This PR was created with the assistance of GitHub Copilot.

Summary

Fixes the library-tests regression from #126407 tracked in #127257.

#126407 switched the WASM framework / webcil static web asset CopyToOutputDirectory from PreserveNewest to Never, which is correct for dotnet run (static web assets middleware serves files out of obj/fx/). But library tests in this repo run the app directly from bin/ without the middleware, so the framework files are missing and loading dotnet.*.js fails.

Changes

  • Microsoft.NET.Sdk.WebAssembly.Browser.targets: introduce a private MSBuild property _WasmFrameworkCopyToOutputDirectory (default Never) and route the three CopyToOutputDirectory values through it (Computed/webcil assets, Framework assets, and the post-UpdatePackageStaticWebAssets item update).
  • eng/testing/tests.browser.targets: set _WasmFrameworkCopyToOutputDirectory to PreserveNewest so library tests copy framework assets to the output directory as before.

Default behavior for regular dotnet run / Blazor WASM scenarios is unchanged.

… asset copy

Introduce a private MSBuild property _WasmFrameworkCopyToOutputDirectory that
switches CopyToOutputDirectory between 'Never' (default) and 'PreserveNewest'
for WASM framework/webcil static web assets in Microsoft.NET.Sdk.WebAssembly.Browser.targets.

Enable it with 'PreserveNewest' in eng/testing/tests.browser.targets so library
tests that run from bin/ without the static web assets middleware can still find
the framework files. Fixes the regression from dotnet#126407 tracked in dotnet#127257.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 22, 2026 16:03
@maraf
Copy link
Copy Markdown
Member Author

maraf commented Apr 22, 2026

/azp run runtime-wasm

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@maraf maraf added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Apr 22, 2026
@maraf maraf added this to the 11.0.0 milestone Apr 22, 2026
@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.

Copy link
Copy Markdown
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 addresses a regression in in-tree WASM library tests by making the WebAssembly SDK’s framework/webcil static web asset CopyToOutputDirectory behavior configurable, while keeping the default behavior for typical dotnet run unchanged (assets served from intermediate locations via static web assets).

Changes:

  • Introduce a private MSBuild property _WasmFrameworkCopyToOutputDirectory (default Never) and route relevant CopyToOutputDirectory values through it.
  • Set _WasmFrameworkCopyToOutputDirectory=PreserveNewest for browser test builds so framework assets are present under bin/ for direct execution.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets Adds _WasmFrameworkCopyToOutputDirectory and uses it to control whether framework/webcil static web assets are copied to output during build.
eng/testing/tests.browser.targets Forces _WasmFrameworkCopyToOutputDirectory=PreserveNewest for in-tree browser tests that run from bin/ without static web assets middleware.

@maraf
Copy link
Copy Markdown
Member Author

maraf commented Apr 23, 2026

/ba-g Windows variant of library tests passed. Merging to unblock CI

@maraf maraf merged commit 9ffefca into dotnet:main Apr 23, 2026
61 of 77 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.

3 participants