Repository navigation
Description
Describe the bug
When a Razor class library is consumed as a NuGet package, its static web assets get compressed (.gz / .br) endpoints only on their plain route. The fingerprinted route, which is what @Assets["..."] returns, has no Content-Encoding selectors, so MapStaticAssets always serves it uncompressed.
The same library consumed as a project reference gets both compressed variants on the fingerprinted route, as expected.
So with a package reference, following the template guidance (@Assets[...] + MapStaticAssets) for a library stylesheet makes it larger on the wire than linking it by its plain path. In our app, a 429 KB library stylesheet went out raw under its fingerprinted name and as 63 KB of Brotli under its plain name.
The SDK-generated @import of a package's <Lib>.<fp>.bundle.scp.css in the app's scoped CSS bundle is affected in the same way, and an app cannot work around that one.
This may share a root cause with #54907.
To reproduce (SDK 10.0.100, Linux)
dotnet new razorclasslib -n DemoLib -o DemoLib
mkdir -p DemoLib/wwwroot/css
python3 -c "print('.demo{color:red}\n'*4000)" > DemoLib/wwwroot/css/demo.css
dotnet pack DemoLib -c Release -o feed -p:Version=1.0.0
dotnet new blazor -n DemoApp -o DemoApp --interactivity Server --empty
# nuget.config in DemoApp pointing at ./feed, then:
dotnet add DemoApp package DemoLib --version 1.0.0
dotnet publish DemoApp -c Release -o pubThen list the endpoints for demo in pub/DemoApp.staticwebassets.endpoints.json (Route | AssetFile | Content-Encoding selector).
Package reference:
_content/DemoLib/css/demo.0q6p3fhpob.css | _content/DemoLib/css/demo.css | []
_content/DemoLib/css/demo.css | _content/DemoLib/css/demo.css | []
_content/DemoLib/css/demo.css | _content/DemoLib/css/demo.css.gz | ['gzip']
_content/DemoLib/css/demo.css | _content/DemoLib/css/demo.css.br | ['br']
_content/DemoLib/css/demo.css.br | _content/DemoLib/css/demo.css.br | []
_content/DemoLib/css/demo.css.gz | _content/DemoLib/css/demo.css.gz | []
Project reference (dotnet add DemoApp reference DemoLib/DemoLib.csproj instead):
_content/DemoLib/css/demo.0q6p3fhpob.css | _content/DemoLib/css/demo.css.gz | ['gzip']
_content/DemoLib/css/demo.0q6p3fhpob.css | _content/DemoLib/css/demo.css.br | ['br']
_content/DemoLib/css/demo.0q6p3fhpob.css | _content/DemoLib/css/demo.css | []
_content/DemoLib/css/demo.0q6p3fhpob.css.br | _content/DemoLib/css/demo.css.br | []
_content/DemoLib/css/demo.0q6p3fhpob.css.gz | _content/DemoLib/css/demo.css.gz | []
_content/DemoLib/css/demo.css | ... (same as above, plain route)
Expected behavior
A package asset's fingerprinted route gets the same gzip / br endpoints as a project-reference asset, so @Assets[...] and the scoped bundle @import are served compressed.
Notes
This looks like it's because a package asset's relative path carries no #[.{fingerprint}] pattern, so the compressed asset's path (css/demo.css.gz) never produces a fingerprinted compressed endpoint for compression negotiation to attach to. None of the switches in Microsoft.NET.Sdk.StaticWebAssets.Compression.targets change this; they only choose which assets and formats are compressed.
Activity
github-actions commentedon Oct 14, 2026
🎯 Agentic Issue Triage
Triage Assessment:
@javiercn|@dotnet/aspnet-blazor-enghigh- Issue directly concerns Static Web Assets compression endpoints, and the CODEOWNERS section is unambiguous.Similar issues: #54907 (
potentially related)➡️ Summary: Package-consumed static web assets lack gzip/br endpoints on their fingerprinted route, unlike project references, so
@Assets[...]serves uncompressed content. Investigate how package asset endpoints are generated for compression.