17

I have updated my visual studio 2019 to latest version with .net 5 after that any project with .net core 2.2 gives this error Error MSB4018 The "RazorGenerate" task failed unexpectedly. System.InvalidOperationException: DOTNET_HOST_PATH is not set at Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask.get_DotNetPath()

After one day try to run the project i find out that you have to install from huget PackageReference Include="Microsoft.NET.Sdk.Razor" Version="2.2.0" to solve the problem

1
  • 3
    It sounds like you encountered a problem, and then solved your problem. It's fine to post a question and then answer it. But you should post your answer as an answer, not embed it into your question. That way, your question will show up as answered for people struggling with a similar problem. Commented Nov 13, 2020 at 21:54

2 Answers 2

12

After one day try to run the project i find out that you have to install from nuget PackageReference Include="Microsoft.NET.Sdk.Razor" Version="2.2.0" to solve the problem

1
  • 1
    worked perfect, for me was v3.x to solve for asp.net core 3.x projects
    – Tab
    Commented Dec 22, 2020 at 16:04
1

This is something issue with VS. for me I have added 'DOTNET_HOST_PATH' path with %ProgramFiles%\dotnet\dotnet.exe . and restarted . problem solevd

Not the answer you're looking for? Browse other questions tagged or ask your own question.