本文介绍了使用Cake构建引用Net-Standard库的Net Framework Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have two projects: NET Standard class library and regular NET Framework web application. Web application references class library.

我使用Visual Studio 2017 Preview.

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

When I try to build the solution with Cake using MSBuild command I get the unsupported project message:

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 MSBuild 2003 format.

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 MSBuild 2003 format.

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

If I try to use DotNetCoreBuild I get:

error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.0.2-vspre-006949\Microsoft\VisualStudio\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.

error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.0.2-vspre-006949\Microsoft\VisualStudio\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成功构建的.

But the solution is built successfully by Visual Studio.

推荐答案

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

Latest MSBuild version has the targets to build NET Standard libraries. The problem is in Visual Studio Preview installation path: Cake can't find the latest MSBuild.

如果您尝试在 MSBuildToolVersion .

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

You have to specify the MSBuild executable manually to make it work with 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安装.

Update by @Gary Ewan Park: there is a tool for determining latest VS install.

这篇关于使用Cake构建引用Net-Standard库的Net Framework Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 11:48