Roslyn, MSBuildWorkspace compiling a .NetStandard project referencing a .NetStandard project throws “No value for RuntimeMetadataVersion found.”

我的未来我决定 提交于 2019-12-02 07:12:05

To address this, here are the steps you need to take:

  1. Reference the Microsoft.Build.Locator NuGet package.
  2. Call MSBuildLocator.RegisterDefaults(); before creating the MSBuildWorkspace
  3. Make sure that there aren't any Microsoft.Build.* assemblies in your app bin folder (see below).

With those steps I was able to correctly build the 2 projects.

This is how you can remove the files from the output folder (add this to your .csproj or use the Post Build steps in Visual Studio).

  <PropertyGroup>
    <PostBuildEvent>del "$(TargetDir)\Microsoft.Build.dll"
del "$(TargetDir)\Microsoft.Build.Framework.dll"
del "$(TargetDir)\Microsoft.Build.Tasks.Core.dll"
del "$(TargetDir)\Microsoft.Build.Utilities.Core.dll"
    </PostBuildEvent>
  </PropertyGroup>

For additional information please see: https://github.com/dotnet/roslyn/issues/26029

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!