Skip to content

Fix publish-time Framework materialization for multi-client WASM and add test#126211

Open
lewing wants to merge 6 commits intodotnet:mainfrom
lewing:fix-wasm-publish-framework
Open

Fix publish-time Framework materialization for multi-client WASM and add test#126211
lewing wants to merge 6 commits intodotnet:mainfrom
lewing:fix-wasm-publish-framework

Conversation

@lewing
Copy link
Copy Markdown
Member

@lewing lewing commented Mar 27, 2026

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 ApplyCompressionNegotiation when multiple WASM clients are published by a single server.

Root Cause

The publish-time ConvertDllsToWebcil (line 788) was not capturing PassThroughCandidates, 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.ToAssetDictionary crashed on the duplicate key.

Fix

Mirror the build-time pattern in ProcessPublishFilesForWasm:

  1. Capture PassThroughCandidates from ConvertDllsToWebcil
  2. Remove them from webcil candidates
  3. Route through DefineStaticWebAssets(SourceType="Framework") + UpdatePackageStaticWebAssets for per-project materialization
  4. Define endpoints via DefineStaticWebAssetEndpoints
  5. Set AssetMode=All so assets flow to the hosting server

Test

Adds MultiClientHostedBuildAndPublish test with a dedicated BlazorMultiClientHosted test asset (Server + Client1 + Client2). Parametrized over Debug/Release × build/publish. Verifies:

  • Both clients' framework directories exist
  • Both contain dotnet.*.js and dotnet.native*.wasm files (publish only)
  • No duplicate Identity crash in ApplyCompressionNegotiation

Related

Copilot AI review requested due to automatic review settings March 27, 2026 17:22
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 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 PassThroughCandidates from ConvertDllsToWebcil, remove them from webcil candidates, and route them through DefineStaticWebAssets(SourceType="Framework") + UpdatePackageStaticWebAssets for per-project materialization.
  • Ensure materialized publish framework assets flow to the hosting server by setting AssetMode=All.
  • Add a new MultiClientHostedPublish test 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.

@lewing lewing added the NO-REVIEW Experimental/testing PR, do NOT review it label Mar 27, 2026
@lewing lewing force-pushed the fix-wasm-publish-framework branch from 6262748 to bb2e8f2 Compare March 27, 2026 18:23
@lewing lewing changed the title Fix WASM publish path for Framework SourceType materialization Add MultiClientHostedPublish test for WASM Framework materialization Mar 27, 2026
@lewing lewing removed the NO-REVIEW Experimental/testing PR, do NOT review it label Mar 27, 2026
@lewing lewing marked this pull request as ready for review March 27, 2026 18:30
@lewing lewing requested review from ilonatommy and maraf as code owners March 27, 2026 18:30
Copilot AI review requested due to automatic review settings March 27, 2026 18:30
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

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

@lewing lewing force-pushed the fix-wasm-publish-framework branch from bb2e8f2 to 937e46b Compare March 27, 2026 18:37
@lewing lewing force-pushed the fix-wasm-publish-framework branch from 937e46b to 0dc907a Compare March 27, 2026 21:39
Copilot AI review requested due to automatic review settings March 27, 2026 21:39
@lewing lewing enabled auto-merge (squash) March 27, 2026 21:42
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

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

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

@lewing lewing force-pushed the fix-wasm-publish-framework branch from 0d1e07e to 8b63775 Compare March 28, 2026 19:06
Copilot AI review requested due to automatic review settings March 29, 2026 00:49
@lewing lewing force-pushed the fix-wasm-publish-framework branch from 8b63775 to 50bfed5 Compare March 29, 2026 00:49
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

…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>
@lewing lewing force-pushed the fix-wasm-publish-framework branch from 50bfed5 to 535454f Compare March 29, 2026 00:56
…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>
Copilot AI review requested due to automatic review settings March 30, 2026 00:30
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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

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>
Copilot AI review requested due to automatic review settings March 30, 2026 20:25
@lewing lewing requested a review from akoeplinger as a code owner March 30, 2026 20:25
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

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

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>
@lewing lewing force-pushed the fix-wasm-publish-framework branch from 6fb52c5 to b8b5386 Compare March 30, 2026 20:35
@lewing lewing changed the title Add MultiClientHostedPublish test for WASM Framework materialization Fix publish-time Framework materialization for multi-client WASM and add test Mar 30, 2026
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>
Copilot AI review requested due to automatic review settings March 30, 2026 21:24
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

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

…oft.NET.Sdk.WebAssembly.Browser.targets

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 30, 2026 21:39
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

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants