Skip to content

Non-framework JavaScript files fail to load due to unintended fingerprint markers #64060

@yamachu

Description

@yamachu

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

According to the documentation, there appear to be two ways to enable client-side fingerprinting:

  1. Add the marker #[.{fingerprint}] to references so that non-framework static files are fingerprinted.
  2. Use the StaticWebAssetFingerprintPattern attribute to control which assets get fingerprinted.

However, when I run dotnet publish for a Blazor WebAssembly app, the generated index.html automatically includes fingerprint markers for JavaScript files under wwwroot that are not part of the Blazor framework. The problem is that the actual file names are not rewritten to include the fingerprint. As a result, when hosting the contents of publish/wwwroot, those script requests return 404 errors because the referenced (fingerprinted) logical names do not exist on disk.

GET http://[::]:8000/lib/bootstrap/dist/js/bootstrap.bundle.min.493y06b0oq.js net::ERR_ABORTED 404 (File not found)
GET http://[::]:8000/lib/bootstrap/dist/js/bootstrap.29cdq58tmq.js net::ERR_ABORTED 404 (File not found)

Expected Behavior

If I do NOT configure any StaticWebAssetFingerprintPattern, non-framework JavaScript files should be referenced as-is (without fingerprint markers).
Alternatively, if fingerprinting markers are added, the process should be consistent (either rewrite file names accordingly or avoid adding markers).

This appears aligned with the workaround mentioned in this issue comment:
#62211 (comment)

Including the following in the project fixes the inconsistency:

<StaticWebAssetFingerprintPattern Include="JS" Pattern="*.js" Expression="#[.{fingerprint}]!" />

Additionally, it is desirable for the template to work as is.

Steps To Reproduce

  1. Install .NET 10 RC2
  2. Run: dotnet new blazorwasm -f net10.0
  3. Run: dotnet publish
  4. Host the published app, e.g.:
cd bin/Release/net10.0/publish/wwwroot
python3 -m http.server
  1. Open the site in a browser and observe 404 errors for some JavaScript references.

Exceptions (if any)

No response

.NET Version

10.0.100-rc.2.25502.107

Anything else?

Using microsoft.dotnet.web.projecttemplates.10.0.10.0.0-rc.2.25502.107.nupkg
wasm-tools 10.0.100-rc.2.25502.107/10.0.100-rc.2 SDK 10.0.100-rc.2

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions