Skip to content

Static Web Assets with Finger Printing in Razor Class Libraries not supported? #58976

@Tornhoof

Description

@Tornhoof

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Having a Razor Class Library with the new Static Web Assets with Fingerprinting enabled does not load the bundled and fingerprinted main asset ProjectName.bundle..scp.css, instead it tries to load the ProjectName.styles.css which does not exist. (404)
If I use MapStaticAssets with the endpoints.json, the status code is 200, but the result is length 0.

Background
I have multiple blazor WebApp as Razor Class libraries distributed as nuget packages, which are reused multiple times in different main solutions (which are not blazor apps,but usually simple web api apps with rest apis).
In .NET 8 times it was already not possible to use "ProjectName.styles.css" logic, but I had to manually reference "ProjectName.bundle.scp.css" and other bundled css (like for quickgrid).

But now with fingerprinting, the bundle has no fixed name anymore. Fingerprinting can be disabled via the rather undocumented csproj setting "StaticWebAssetFingerprintingEnabled" (thanks to @ViRuSTriNiTy who told me that in Discussions #58910), but that does not disable fingerprinting with externally packaged nugets like Quickgrid.

Expected Behavior

The assets are properly loaded, even if the hosting application is not a blazor app, but the Blazor App is packaged as a nuget package.

There is an api/way to reference assets with fingerprinting in razor class libraries or it is properly documented that you still need to reference the un-fingerprinted one, because the endpoint for it exists.

Steps To Reproduce

  1. Clone https://github.com/Tornhoof/BlazorClassLibRepro
  2. Run in Visual Studio, entrypoint is the Runner.csproj
  3. It should open a browser for https://localhost:7003/app
  4. The assets are not properly loaded

Notes:

  • In App.razor in BlazorApp it is possible to uncomment the manual bundle references if you disable the fingerprinting.

Exceptions (if any)

No response

.NET Version

9.0.100

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions