RazorTagHelper - DOTNET_HOST_PATH is not set -Error MSB4018

Posted by jineesh uvantavida on Wednesday, December 2, 2020 Under: asp.net

After updating VS 2019 16.8.2 There will be an error on compilation on any project:


dot net --version : 5.0.100

Severity Code Description Project File Line Suppression State

Error MSB4018 The "RazorGenerate" task failed unexpectedly.
System.InvalidOperationException: DOTNET_HOST_PATH is not set at Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask.get_DotNetPath()
at Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask.GenerateFullPathToTool()
at Microsoft.Build.Utilities.ToolTask.ComputePathToTool() at Microsoft.Build.Utilities.ToolTask.Execute()
at Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
C:\Users\DELL\.nuget\packages\microsoft.aspnetcore.razor.design\2.2.0\build\netstandard2.0
\Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets 131



Solution 1:

Add the following environment variable to user environment to make it build again:
DOTNET_HOST_PATH
%ProgramFiles%\dotnet\dotnet.exe

Solution 2:

If the above solution not worked, you can try setting the same manually through cmd.
setx DOTNET_HOST_PATH "%ProgramFiles%\dotnet\dotnet.exe"

In : asp.net 


Tags: razortaghelper - dotnet_host_path is not set msb4018 

Translate This Page

 


Make a free website with Yola