'Blazor ignoring scoped CSS in Components

I have a similar problem as mentioned here.

The component MyComponent.razor has the scoped CSS MyComponent.razor.css. Anyways, the style of the CSS file SOMETIMES is ignored. If I change the CSS it might work on the first start, or it might happen that I have to build the project 10 times before it works. If I move the Component (including the scoped CSS) from one folder to another and move it back, it is more likely to work as well.

It is also not a caching issue. When I hard refresh the browser and clear the cache, the CSS is still not loaded. In the dev tools, I am also not able to find the specific changes in the bundled CSS. E.g., if in the CSS I simply change the background-color of a class from blue to red, the background-color is still blue in the bundled CSS.

Within my _Host.cshtml the bundled style is added.

<head>
...
    <link href="<applicationName>.Client.styles.css" rel="stylesheet" />
</head>

Project.Client.csproj does not contain a

<RazorLangVersion>3.0</RazorLangVersion>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source