从命令行构建 NET471 和 netstandard 2.0 解决方案

Build NET471 & netstandard 2.0 solution from the command line

是否可以从命令行编译 NET471 和 netstandard(和 netcoreapp)2.0 解决方案?

我有一个包含 netstandard 2.0 库、netcoreapp 2.0 项目和 WPF Net 4.7.1 测试应用程序的解决方案。

现在我尝试以两种方式构建解决方案,但每种方式都不支持相反的框架。

MSBuild

MSBuild.exe .\MySolution.sln

class 库出错:

C:\Development\TestLibrary.csproj(1,1): error MSB4041: The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored i n the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.

DOTNET 构建

dotnet build .\MyTestSolution.sln

C:\Program Files\dotnet\sdk.0.2\Microsoft.Common.CurrentVersion.targets(2925,5): error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files\dotnet\sdk.0.2\MSBuild.exe" exists and can be run. [C:\Development\MyTestApp.csproj]

注意:我不想将多个框架目标添加到我的 NETStandard 库中(我最近刚刚将它们从 NET47 中删除),此外 MSBuild 似乎不支持新的 csproj 格式。

感谢@Martin Ullrich 的评论,我已经弄明白了。

添加最新的 MSBuild 版本

重新启动我的 PowerShell,现在显示正确的版本