简体   繁体   中英

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.

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 .

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.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM