【问题标题】:Build Net Framework web application referencing net-standard library with Cake build使用 Cake build 构建引用网络标准库的 Net Framework Web 应用程序
【发布时间】:2017-09-12 14:57:00
【问题描述】:

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

我使用Visual Studio 2017 Preview

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

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 成功构建的。

【问题讨论】:

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


    【解决方案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 更新:有一个tool 用于确定最新的 VS 安装。

    【讨论】:

    • 你可能想看看这里:cakebuild.net/blog/2017/03/… 而不是硬编码路径。
    • @Michael,感谢您在这里分享您的解决方案,您可以将其标记为答案,这样可以帮助遇到相同问题的其他社区成员。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-23
    • 2021-05-08
    • 2019-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    相关资源
    最近更新 更多