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

前端 未结 1 1868
难免孤独
难免孤独 2021-01-15 00:37

Create a solution with the following projects.

A .NetStandard2.0 project, name it \"1\"

A .NetStandard2.0 project, name it \"2\"

Add a reference of p

1条回答
  •  无人共我
    2021-01-15 01:19

    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).

      
        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"
        
      
    

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

    0 讨论(0)
提交回复
热议问题