Is there a problem with .NET 8 and Blazor or just a problem with my project? I have a common assembly so I can build as either Maui or Web Assembly. I've done this before. I have a .NET 6 and .NET 7 projects, set up the same way, where it's all working as expected.
So, I think it's all set up ok:
<link rel="stylesheet" href="_content/CommonAssembly/css/bootstrap/bootstrap.min.css" /> <!-- Loads -->
<link rel="stylesheet" href="_content/CommonAssembly/css/app.css" /> <!-- Loads -->
<link rel="stylesheet" href="CommonAssembly.styles.css" /> <!-- Does not load -->
The styles.css file about does not load.
The main layout and the individual views are also in CommonAssembly. These also load.
But when the app launches and it tries to load:
https://0.0.0.0/CommonAssembly.styles.css
The file is not found and can't be loaded.
The external assembly is registered in my routes:
<Router AppAssembly="@typeof(MauiProgram).Assembly" AdditionalAssemblies="new[] {typeof(MainLayout).Assembly}">
Has anyone come across this with .NET 8? Can anyone suggest something I can try?
My mistake was assuming the isolated css would be loaded from the common assembly. When the project builds, it builds the isolated CSS into the main assembly so I had to replace:
<link rel="stylesheet" href="CommonAssembly.styles.css" />
With:
<link rel="stylesheet" href="MainAssembly.styles.css" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With