I have a Blazor server app with a client project. In the client project, I have a bunch of pages and components. Adding a file with the same name as the razor page with the CSS extension worked so far to create scoped CSS files… But somehow not anymore.
I added a new page under the page's folder. Named Historia.razor
. Added a Historia.razor.css
file in the same folder. Visual Studio understands it nicely and nests the CSS page under the main razor file.
But when compiling and running the app, the styles do not appear. I checked the combined CSS file (MyApp.styles.css
) and there are no entries from the Historia.razor.css
file. Also checked the styles on the generated page and they don't contain the b-213321 extra ID on the class names.
I checked the project file to ensure the file is not under the "ignore", It is not. This is what the project file looks like:
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazored.Toast" Version="3.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.3" />
</ItemGroup>
<ItemGroup>
<Watch Include="**\*.razor" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\VikingBoardGames.Shared.csproj" />
</ItemGroup>
</Project>
Once again, it DOES WORK for other components and pages that I added in the past and follows the same exact folder/naming structure.
Any ideas on what is preventing the CSS to be bundled with the rest?
NOTE: After doing a clean - build -delete .vs folder - restart VS as suggested by Henk Holterman my tags do show the b-312412wgz code. But still, the styles are not applied and the CSS content is not added to the myproject.styles.css file.
I tried also to create a new file, with its CSS file. Exactly the same behavior.
<div class="MainDiv" b-2134234wgp>
But the CSS file is not included in the combined styles.css file. And the tag does not exhibit any of its definitions. – Conti