Using .NET 9 and a Blazor web app (with server interactive rendering mode), I'm struggling to get static assets (or CSS isolation bundles) from a Razor class library to work with my Blazor web app.
I have followed Microsoft's instructions and my .razor file has a .razor.css as a child. In addition I've created a wwwroot with a styles2.css file in it.
The RCL is dynamically loaded through
app.MapRazorComponents<App>().AddAdditionalAssemblies()The RCL is definitely loaded as a page defined in Components/Pages/MyPage.razor in the RCL, using @page /myurl, is accessible from /myurl.
When running the app I can find neither the bundle nor the CSS file. I've tried various version of the supposed syntax, but none work:
_content/MyRclAssemblyName/MyRclAssemblyName.bundle.scp.css_content/MyRclAssemblyName/styles2.cssMyRclAssemblyName/MyRclAssemblyName.bundle.scp.cssMyRclAssemblyName/styles2.css- Probably more but I've forgotten
Adding this to the WebApplicationBuilder has no effect:
builder.WebHost.UseWebRoot("wwwroot");builder.WebHost.UseStaticWebAssets();Though this is not really surprising as per the documentation
running the consuming app from build output (dotnet run), static web assets are enabled by default in the Development environment.
My suspicion is that because this is added through .AddAdditionalAssemblies() that this creates some weird scenario where you need additional configuration that is not documented or hidden in a way that I've overlooked it.
How can I use static assets, or CSS bundles, from a Razor class library that is dynamically loaded through .AddAdditionAssembles() and not referenced directly?