使用Cake build

时间:2017-09-12 14:57:01

标签: c# visual-studio msbuild .net-standard cakebuild

我有两个项目:NET Standard类库和常规的.NET Framework Web应用程序。 Web应用程序引用类库。

我使用Visual Studio 2017 Preview

当我尝试使用Cake命令使用MSBuild构建解决方案时,我得到了不受支持的项目消息:

error MSB4041: The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the <Project> element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MS Build 2003 format.

如果我尝试使用DotNetCoreBuild,我会:

error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.0.2-vspre-006949\Microsoft\VisualStu dio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

但该解决方案是由Visual Studio成功构建的。

1 个答案:

答案 0 :(得分:1)

最新的MSBuild版本具有构建NET Standard库的目标。问题出在Visual Studio Preview安装路径中:Cake无法找到最新的MSBuild

如果您尝试在MSBuildToolVersion中指定VS2017,它也会失败。

您必须手动指定MSBuild可执行文件才能使其与VS Preview一起使用。

string msBuildPath = @"c:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\MSBuild\15.0\Bin\MSBuild.exe";

MSBuild("../NetStdExample.sln", new MSBuildSettings {
    Verbosity = Verbosity.Minimal,
    ToolPath = msBuildPath
});

@Gary Ewan Park更新:确定最新的VS安装有tool