我有两个项目: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成功构建的。
答案 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。