Fix publish-time Framework materialization for multi-client WASM and add test#126211
Open
lewing wants to merge 6 commits intodotnet:mainfrom
Open
Fix publish-time Framework materialization for multi-client WASM and add test#126211lewing wants to merge 6 commits intodotnet:mainfrom
lewing wants to merge 6 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the WASM publish static web assets pipeline with the existing build pipeline by correctly classifying and materializing shared runtime-pack “pass-through” assets as SourceType="Framework", preventing duplicate Identity collisions in multi-client hosted/published scenarios.
Changes:
- Capture publish-time
PassThroughCandidatesfromConvertDllsToWebcil, remove them from webcil candidates, and route them throughDefineStaticWebAssets(SourceType="Framework")+UpdatePackageStaticWebAssetsfor per-project materialization. - Ensure materialized publish framework assets flow to the hosting server by setting
AssetMode=All. - Add a new
MultiClientHostedPublishtest to validate multi-client hosted publish succeeds and produces expected framework outputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets |
Mirrors build-time Framework materialization in the publish target to avoid duplicate SWA identities and ensure assets propagate to the server on publish. |
src/mono/wasm/Wasm.Build.Tests/Blazor/MiscTests.cs |
Adds coverage for multi-client hosted publish to catch regressions in the publish-time static web assets pipeline. |
...nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets
Show resolved
Hide resolved
6262748 to
bb2e8f2
Compare
bb2e8f2 to
937e46b
Compare
maraf
approved these changes
Mar 27, 2026
937e46b to
0dc907a
Compare
0dc907a to
639898d
Compare
This was referenced Mar 28, 2026
Open
639898d to
0d1e07e
Compare
0d1e07e to
8b63775
Compare
8b63775 to
50bfed5
Compare
…lization Add a proper BlazorMultiClientHosted test asset with two distinct WASM client projects (Client1, Client2) and a server project, each with unique content and StaticWebAssetBasePath. This replaces the synthetic test setup that cloned BlazorBasicTestApp and deleted files to avoid collisions. The test validates that Framework SourceType materialization produces per-project Identity values that work correctly through both the build and publish pipelines. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
50bfed5 to
535454f
Compare
…asset name
The test harness expects a .csproj named after the TestAsset.Name property
('BlazorMultiClientHosted') in the RunnableProjectSubPath directory.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
src/mono/wasm/testassets/BlazorMultiClientHosted/Client2/Client2.csproj
Outdated
Show resolved
Hide resolved
src/mono/wasm/testassets/BlazorMultiClientHosted/Server/BlazorMultiClientHosted.csproj
Outdated
Show resolved
Hide resolved
src/mono/wasm/testassets/BlazorMultiClientHosted/Client1/Client1.csproj
Outdated
Show resolved
Hide resolved
Match the pattern used by all other wasm test assets (BlazorBasicTestApp, BlazorWebWasm, etc.) which hardcode net11.0 and explicit package versions rather than relying on undefined MSBuild properties. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The build path captures PassThroughCandidates from ConvertDllsToWebcil and routes them through DefineStaticWebAssets(SourceType=Framework) + UpdatePackageStaticWebAssets for per-project materialization. The publish path was missing this — pass-through assets (like HotReload dlls) kept their raw SDK path, causing duplicate Identity crashes in ApplyCompressionNegotiation for multi-client hosted Blazor WASM publish. Mirror the build-time pattern: capture PassThroughCandidates, remove them from webcil candidates, define as Framework assets, and materialize to per-project paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6fb52c5 to
b8b5386
Compare
CopyTestAsset already initializes _logPath via InitPaths, which creates the per-test log directory under s_buildEnv.LogRootPath. Use it instead of manually creating a separate directory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
...nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets
Outdated
Show resolved
Hide resolved
…oft.NET.Sdk.WebAssembly.Browser.targets Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the publish-time static web assets pipeline for multi-client hosted Blazor WASM scenarios. The build path was fixed in #125329 but the publish path was missed — pass-through assets (HotReload dlls, native files) kept their raw SDK path, causing duplicate Identity crashes in
ApplyCompressionNegotiationwhen multiple WASM clients are published by a single server.Root Cause
The publish-time
ConvertDllsToWebcil(line 788) was not capturingPassThroughCandidates, unlike the build-time call (line 356). Pass-through assets flowed through with their shared SDK path, and when two clients contributed the same asset to the server,StaticWebAsset.ToAssetDictionarycrashed on the duplicate key.Fix
Mirror the build-time pattern in
ProcessPublishFilesForWasm:PassThroughCandidatesfromConvertDllsToWebcilDefineStaticWebAssets(SourceType="Framework")+UpdatePackageStaticWebAssetsfor per-project materializationDefineStaticWebAssetEndpointsAssetMode=Allso assets flow to the hosting serverTest
Adds
MultiClientHostedBuildAndPublishtest with a dedicatedBlazorMultiClientHostedtest asset (Server + Client1 + Client2). Parametrized over Debug/Release × build/publish. Verifies:dotnet.*.jsanddotnet.native*.wasmfiles (publish only)ApplyCompressionNegotiationRelated
ProcessPublishFilesForWasm→ConvertDllsToWebcil→ lostPassThroughCandidates→ApplyCompressionNegotiationcrash onHotReload.WebAssembly.Browser.dll