'Blazor Razor Class Library (RCL) No CSS Intellisense
I have a razor class library (RCL) that contains all the pages from my blazor application. The CSS intellisense does not seem to work within the RCL unless I change the RCL .csproj xml tag From Sdk="Microsoft.NET.Sdk.Razor" To Sdk="Microsoft.NET.Sdk.Web" .
Example: <p class="..(no intellisense is shown if used within an RCL)"
I am using VS2022 with the latest updates. Any information that can help resolve this issue, is appreciated.
Solution 1:[1]
I wrote an extension, that tackles this exact problem.
It should solve your problem, as it scans every project that exists in the solution, not just the ones of the type Microsoft.NET.Sdk.Web
.
Furthermore, it also adds support for isolated CSS contexts (*.razor.css files), as well as external files, which are linked via the <link> attribute in an HTML file.
You can find more info about it in the GitHub repo.
Solution 2:[2]
It seems Blazor css intellisense is not that great. So my work around was to change the .csproj to Sdk="Microsoft.NET.Sdk.Web" reload the solution and then add a "Program.cs" class file to the root with one line of code.
It doesn't matter what that line of code does just add a line of code. In my project I added a variable like var workAround="empty";
to the program.cs file.
Now the css intellisense magically works. It doesn't work that great but it works. Microsoft needs to fix this.
Another thing to add is to close visual studio and delete the .vs folder. This is a hidden folder where you project resides.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | KevinMueller |
Solution 2 |