After Update VS2019 16.8.1 I receive and build error MSB4018. What can I do?

Christof Oberholzer 1 Reputation point
2020-11-13T23:57:40.35+00:00

Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand
Fehler MSB4018 Unerwarteter Fehler bei der RazorGenerate-Aufgabe. --> Unexpected Error on RazorGenerate Task
System.InvalidOperationException: DOTNET_HOST_PATH is not set
bei Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask.get_DotNetPath()
bei Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask.GenerateFullPathToTool()
bei Microsoft.Build.Utilities.ToolTask.ComputePathToTool()
bei Microsoft.Build.Utilities.ToolTask.Execute()
bei Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask.Execute()
bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
bei Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() WorkCollaboration C:\Users\christofoberholzer.BBV.nuget\packages\microsoft.aspnetcore.razor.design\2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets 131

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,960 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Mahdi Shams 6 Reputation points
    2020-11-15T06:49:14.17+00:00

    It worked on the build server, after I added this Nuget package:

    Microsoft.NET.Sdk.Razor

    Since I added the Net.SDK.Razor package, it builds successfully.

    I had also added Microsoft.AspNetCore.Razor.Design, but only Microsoft.NET.Sdk.Razor is actually needed.

    1 person found this answer helpful.
    0 comments No comments

  2. KOB 1 Reputation point
    2020-11-15T15:47:05.47+00:00

    I inserted this line into .csproj
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0"> <ExcludeAssets>Build</ExcludeAssets>

    <Project Sdk="Microsoft.NET.Sdk.Web">
    <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    </PropertyGroup>
    <ItemGroup>
    <PackageReference Include="BuildBundlerMinifier" Version="2.9.406" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.8" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.1" />
    <PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="2.0.8" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
    <PackageReference Include="NLog.Web.AspNetCore" Version="4.9.0" />
    <PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.20" />
    <PackageReference Include="ThaiBahtText" Version="1.0.103" />
    <PackageReference Include="WebEssentials.AspNetCore.OutputCaching" Version="1.0.28" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0"> <ExcludeAssets>Build</ExcludeAssets></PackageReference>
    </ItemGroup>
    <ItemGroup>
    <Content Update="Views_ViewImports.cshtml">
    <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </Content>
    <Content Update="Views_ViewStart.cshtml">
    <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </Content>
    </ItemGroup>

    </Project>

    0 comments No comments