【问题标题】:Build NET Framework project that references NETStandard project with Cake build使用 Cake build 构建引用 NETStandard 项目的 NET Framework 项目
【发布时间】:2017-09-12 21:23:40
【问题描述】:

我有两个项目:StdLibNETStandard 2.0 类库和 Console.Framework 这是 .NET Framework 4.6.1 项目。 控制台应用程序引用类库。

我尝试使用Cake build 构建解决方案。 我使用DotNetBuild 方法(link),我得到了这个输出:

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. Build started 9/12/2017 2:35:55 PM. Project "C:\Projects\NetStdExample\NetStdExample.sln" on node 1 (Build target(s)). ValidateSolutionConfiguration: Building solution configuration "Debug|Any CPU". Project "C:\Projects\NetStdExample\NetStdExample.sln" (1) is building "C:\Projects\NetStdExample\NetStdExample.StdLib\NetStdExample.StdLib.csproj" (2) on node 1 (default targets). C:\Projects\NetStdExample\NetStdExample.StdLib\NetStdExample.StdLib.csproj(1,1): 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. Done Building Project "C:\Projects\NetStdExample\NetStdExample.StdLib\NetStdExample.StdLib.csproj" (default targets) -- FAILED.

有没有办法使用Cake 构建这种项目?

【问题讨论】:

    标签: .net msbuild .net-standard cakebuild


    【解决方案1】:

    DotNetBuild 别名是一个较旧的别名,它可以就是否构建做出明智的决定:

    使用 MSBuild 或 XBuild 的指定解决方案。

    即它将查看构建当前运行的机器类型,并运行MSBuildXBuild

    从你的问题的声音来看,这听起来不像你想要的。相反,我认为你是在 DotNetCore Aliases 之后:

    https://www.cakebuild.net/api/Cake.Common.Tools.DotNetCore/DotNetCoreAliases/

    即你可以这样做:

    DotNetCoreBuild(BuildParameters.SolutionFilePath.FullPath);
    

    使用dotnet cli 构建指定的解决方案。

    DotNetBuild 别名很可能会在某个时候被淘汰。

    【讨论】:

    • 这有助于示例控制台应用程序。当我尝试使用DotNetCoreBuild 构建 ASP.NET 项目时,我得到:IntegrationProxy.csproj(303,3): 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 &lt;Import&gt; declaration is correct, and that the file exists on disk. 你知道如何解决这类问题吗?
    • 如果您使用诊断详细程度运行 Cake,如下所示:stackoverflow.com/questions/38658660/… 它会显示正在执行的确切 dotnet cli 命令。如果您可以使用相同的命令并在命令行中手动运行它,这将允许我们查看问题是出在 Cake 上,还是出在您的环境中。
    • 看来问题不在于Cake,而在于项目引用。 dotnet build 无法构建常规的 .net 框架项目。但是 Visual Studio 设法以某种方式构建。我很感兴趣如何使用Cake 重新创建 VS 行为。我会进一步调查。谢谢!
    • 查看网络应用解决方案:link
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-12
    • 1970-01-01
    • 2018-06-01
    • 2018-05-06
    • 2018-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多