Skip to content

Conversation

maraf
Copy link
Member

@maraf maraf commented Sep 20, 2025

When Blazor Wasm project is referenced from an AspNetCore server project, we need to compute _BlazorJSFile to correctly replace StaticWebAssets _ReplaceFingerprintedBlazorJsForPublish.

To mitigate that the Server project already contains assets for blazor.js from build (and removing them inside of the nested build isn't enough), we define the SWA for blazor.js AssetKind=Build and AssetKind=Publish if fingerprinting is enabled.

This needs to be backported to .NET 10.

Fixes dotnet/runtime#119886

@maraf maraf added this to the 11.0.1xx milestone Sep 20, 2025
@maraf maraf added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label Sep 20, 2025
Copy link
Contributor

This PR is targeting main, which is now for .NET 11-facing work. If you intended to target .NET 10, either retarget this PR to release/10.0.1xx or make sure you backport the change to release/10.0.1xx after merging. See #50394 for more details.

@maraf maraf self-assigned this Sep 20, 2025
@maraf maraf marked this pull request as ready for review September 20, 2025 17:48
@maraf maraf requested a review from a team as a code owner September 20, 2025 17:48
@maraf maraf requested review from Copilot and removed request for a team September 20, 2025 17:48
Copy link
Contributor

@Copilot 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 fixes an issue with fingerprinted Blazor JS file replacement when a Blazor WebAssembly project is referenced from an ASP.NET Core server project. The fix ensures proper computation of _BlazorJSFile and modifies the static web asset handling to prevent asset conflicts during the publish process.

  • Refactors _BlazorJSFile computation into a separate target for better dependency management
  • Modifies asset kind handling to use Build for fingerprinted assets and Publish for replacement assets
  • Adds comprehensive test coverage for both fingerprinted and non-fingerprinted scenarios

Reviewed Changes

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

File Description
src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets Core fix - refactors JS file resolution and asset kind handling for proper fingerprinting
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/WasmPublishIntegrationTest.cs Adds test method to verify the fix works for both fingerprinted and non-fingerprinted scenarios
test/TestAssets/TestProjects/BlazorWasmReferencedByAspNetCoreServer/* Complete test project structure with server and client projects to reproduce the issue

@maraf
Copy link
Member Author

maraf commented Sep 20, 2025

/backport to release/10.0.1xx

Copy link
Contributor

Started backporting to release/10.0.1xx: https://github.com/dotnet/sdk/actions/runs/17882989747

Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. One question that I had is, doesn't the original repro include a PWA? I'm curious as to why this scenario failed and other similar scenarios on the tests didn't.

What's special about this asset configuration?

@maraf
Copy link
Member Author

maraf commented Sep 21, 2025

The original repro contained PWA, but the failure was happening without it as well.

I'm not sure if test Blazor Wasm referenced by AspNetCore server and doing publish.

@maraf
Copy link
Member Author

maraf commented Sep 22, 2025

Closed in favor of #50949

@maraf maraf closed this Sep 22, 2025
@MichaelSimons MichaelSimons deleted the maraf/BlazorWasmReferencedFingerprintPublish branch September 29, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_ReplaceFingerprintedBlazorJsForPublish incorrectly computes assets

2 participants