Skip to content

[release/11.0.1xx-preview1] Backport #52816#52879

Open
lewing wants to merge 2 commits intorelease/11.0.1xx-preview1from
backport-52816
Open

[release/11.0.1xx-preview1] Backport #52816#52879
lewing wants to merge 2 commits intorelease/11.0.1xx-preview1from
backport-52816

Conversation

@lewing
Copy link
Member

@lewing lewing commented Feb 6, 2026

Backport of #52816 to release/11.0.1xx-preview1, based on @maraf's PR #52710.

Customer Issue

When multiple Blazor WASM client projects (e.g., FirstClient and SecondClient) are hosted by a single server project, users encounter a duplicate key error in FilterStaticWebAssetEndpoints. Both clients define the same HotReload JS module (Microsoft.DotNet.HotReload.WebAssembly.Browser.lib.module.js) as a static web asset with identical Identity values, causing the build to fail.

Additionally, the HotReload assembly version could be unpredictable when pulled from NuGet package sources, leading to potential version conflicts between the SDK and the referenced package.

Users cannot easily workaround these issues without modifying their project structure to use a single Blazor WASM client.

Description

This PR fixes both issues by embedding the HotReload functionality directly in the WebAssembly SDK:

  1. Embeds HotReload in SDK: Replaces the PackageReference with content shipped inside the SDK, ensuring consistent versioning
  2. Copy to intermediate folder: The HotReload JS module is copied to hotreload\ before being defined as a StaticWebAsset
  3. Unique Identity: Each project now has a unique Identity for the asset (pointing to their own intermediate folder)
  4. No filter changes needed: The copy-to-intermediate pattern naturally avoids duplicates without modifying filter logic

This follows the established pattern used by JSModules, ScopedCss, and ServiceWorker targets, and @javiercn's guidance: "What we do in other situations with assets like this is to copy them to the intermediate output folder before defining them."

Was this a regression?

  • Yes
  • No

Testing

The Publish_HostingMultipleBlazorWebApps_Works test now passes and validates the fix.

Risk

Low - this follows established patterns used elsewhere in the SDK for similar assets (JSModules, ScopedCss, ServiceWorker), and the change is well-tested. Embedding in the SDK also eliminates version conflicts.

Co-authored-by: Marek Fišera <mara@neptuo.com>
@lewing lewing requested review from a team, akoeplinger, pavelsavara and tmat as code owners February 6, 2026 18:59
Copilot AI review requested due to automatic review settings February 6, 2026 18:59
@lewing lewing requested review from a team and maraf as code owners February 6, 2026 18:59
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

Backport of changes that move the WebAssembly Hot Reload browser artifacts into the WebAssembly SDK layout (instead of an implicit package reference) and updates tests/baselines accordingly.

Changes:

  • Update WebAssembly SDK MSBuild targets to source the Hot Reload JS module/DLL from the SDK layout and define it as a static web asset.
  • Add packaging/build wiring to include the HotReloadAgent.WebAssembly.Browser outputs into the WebAssembly SDK layout.
  • Refresh static web assets test baselines and normalize some test launchSettings values.

Reviewed changes

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

Show a summary per file
File Description
test/TestAssets/TestProjects/WatchBlazorWasmHosted/blazorhosted/Properties/launchSettings.json Switch dotnetRunMessages from string to boolean for the test asset profile.
test/TestAssets/TestProjects/WatchBlazorWasm/Properties/launchSettings.json Switch dotnetRunMessages from string to boolean for the test asset profile.
test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssetsBaselineFactory.cs Extend path templatization to recognize WebAssembly SDK paths.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_Publish_Hosted_Works.Publish.files.json Update expected publish file list baselines for new Hot Reload asset behavior.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_Publish_DoesNotIncludeXmlDocumentationFiles_AsAssets.Publish.files.json Update expected publish file list baselines for new Hot Reload asset behavior.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_PublishMinimal_Works.Publish.staticwebassets.json Update minimal publish static web assets baseline for new Hot Reload module placement/assets.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_PublishMinimal_Works.Publish.files.json Update minimal publish file list baseline.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_Build_Hosted_Works.Build.staticwebassets.json Update hosted build static web assets baseline for new Hot Reload module placement/assets.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_BuildMinimal_Works.Build.staticwebassets.json Update minimal build static web assets baseline for new Hot Reload module placement/assets.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_BuildMinimal_Works.Build.files.json Update minimal build file list baseline to include new Hot Reload outputs.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/Publish_DoesNotGenerateManifestJson_IncludesJSModulesOnBlazorBootJsonManifest.Publish.staticwebassets.json Update publish baseline for JS-module/staticwebassets changes.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/Publish_DoesNotGenerateManifestJson_IncludesJSModulesOnBlazorBootJsonManifest.Publish.files.json Update publish file list baseline.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/JsModules_Hosted_CanCustomizeBlazorInitialization.Publish.files.json Update hosted JS modules publish file list baseline.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/JsModules_CanHaveDifferentBuildAndPublishModules.Publish.staticwebassets.json Update publish static web assets baseline for JS module changes.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/JsModules_CanHaveDifferentBuildAndPublishModules.Publish.files.json Update publish file list baseline for JS module changes.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/JsModules_CanCustomizeBlazorInitialization.Publish.staticwebassets.json Update publish static web assets baseline for JS module changes.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/JsModules_CanCustomizeBlazorInitialization.Publish.files.json Update publish file list baseline for JS module changes.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/JSModules_ManifestIncludesModuleTargetPaths.Build.staticwebassets.json Update build static web assets baseline for JS module changes.
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/Build_DoesNotGenerateManifestJson_IncludesJSModulesOnBlazorBootJsonManifest.Build.staticwebassets.json Update build baseline for JS-module/staticwebassets changes.
src/WasmSdk/Tasks/Microsoft.NET.Sdk.WebAssembly.Tasks.csproj Add project reference + package layout inclusion for HotReloadAgent.WebAssembly.Browser outputs into the WebAssembly SDK.
src/WasmSdk/Sdk/Sdk.targets Add _WasmImplicitlyReferenceHotReload target to copy hot reload JS module to intermediates and define it as a static web asset.
src/BuiltInTools/HotReloadAgent.WebAssembly.Browser/Microsoft.DotNet.HotReload.WebAssembly.Browser.csproj Adjust the HotReload browser agent project to build as a non-Razor SDK project and include wwwroot content in outputs.
build/RunTestsOnHelix.sh Remove adding %DOTNET_ROOT%/.nuget as a NuGet source (now only Testpackages is added).
build/RunTestsOnHelix.cmd Remove adding %DOTNET_ROOT%\\.nuget as a NuGet source (now only Testpackages is added).

- Fix invalid MSBuild ItemGroup syntax: use Update instead of creating empty item
- Update comments in test scripts to reflect actual behavior
- Addresses PR review feedback from copilot-pull-request-reviewer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant