How can I force a specific version of the Razor .cshtml editor in VS? #54068
-
I first asked this on gitter, but @CyrusNajmabadi recommended I post this here
Backstory: I'm the maintainer of RazorGenerator, the embarrassingly slow moving NuGet package and VSIX that enables Razor use in non-ASP.NET projects, and I use RazorGenerator almost daily. My problem is that when I'm using RazorGenerator with a .NET Core (non-ASP.NET Core) project then any I understand that VS 2019 loads either the older V3 Razor editor ( But I want to know how to force VS to open a After some digging inside VS's assemblies, I've found |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 15 replies
-
@NTaylorMullen Do you know the answer to the above? |
Beta Was this translation helpful? Give feedback.
-
After spending too much time in Ghidra, I found the magic incantation... So
So then it's just a matter of editing my .NET Core class library's
Now whenever I open |
Beta Was this translation helpful? Give feedback.
-
Hi @Jehoel and @NTaylorMullen Apologies for the thread necromancy here, but we're seeing this issue pop up again with the release of VS2022. We have a solution that runs on the .NET Framework 4.7.2, ASP.NET MVC 4 with the SDK-style project files. We did the upgrade to the SDK-style csprojs earlier this year, and by adding Now, with VS2022, it seems like it always chooses the Razor V4 editor. The error list is filled with Ok, so in the spirit of doing your homework before asking questions, I tried a couple of different things.
So, any information or help would be very much appreciated, and I'm up for trying any ideas you might have. :) |
Beta Was this translation helpful? Give feedback.
After spending too much time in Ghidra, I found the magic incantation...
So
RazorVersionDetector
(inMicrosoft.WebTools.Languages.Html.VS.dll
, in namespaceMicrosoft.WebTools.Languages.Html.VS.Razor
), performs these checks in sequence:.vbhtml
? If so, then don't use the Razor Core editor.SupportsSystemWeb
capability? Or does the project not have the.NET&CPS
capability?UseRazorV4Editor
MSBuild property.UseRazorV4Editor
is undefined or not set totrue
then use the ASP.NET Web Pages version (described below)UseRazorV4Editor
istrue
then always use the Razor Core editor.