Skip to content

Blazor (server) CSS isolation in Razor Class Library: .styles.css bundle generated but not served (404) #64571

@guillaC

Description

@guillaC

Hello,

I’m building a Blazor Server solution with two projects:

  • DeskUI -> Razor Class Library (Sdk=Razor, RazorClassLibrary=true, ScopedCssEnabled=true, GenerateScopedCss=true, PackageId=DeskUI).
  • DeskUI.Demo -> Blazor Server app (Sdk=Web) that references DeskUI via .
Image

Inside DeskUI I have components with .razor.css files.
During build, MSBuild correctly generates the scoped CSS files (.rz.scp.css) and bundles them into DeskUI.styles.css under obj\Debug\net10.0\scopedcss\bundle.

The issue:
When I run the Demo app and reference the stylesheet in _Host.cshtml:

<link href="_content/DeskUI/DeskUI.styles.css" rel="stylesheet" />

the browser always returns 404 Not Found. Other static assets from the RCL (like drag.js or images in wwwroot) are served correctly via _content/DeskUI/.... Only the DeskUI.styles.css bundle is missing.

Image

What I’ve already checked:

  • Both projects are part of the same solution.
  • Demo is the startup project.
  • UseStaticFiles() is enabled in Program.cs.
  • PackageId matches the _content/DeskUI path.

Clean/rebuild doesn’t help.

The file exists in DeskUI\obj\Debug\net10.0\scopedcss\scopedcss\bundle, but it is not published to _content.

So the problem seems to be that the static web assets pipeline does not expose the generated .styles.css bundle from the Razor Class Library, even though it is created during build.

Has anyone else experienced this issue with Blazor CSS isolation in Razor Class Libraries (on .NET 10)? Is there a known fix or workaround other than manually copying the bundle into the host app’s wwwroot?

I would like to share my Razor library on NuGet, but as it stands this issue is really blocking me. If anyone has a lead, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackThe author of this issue needs to respond in order for us to continue investigating this issue.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