简体   繁体   English

如何在蛋糕中编译.netcore 2.2项目

[英]How to compile .netcore 2.2 project in cake

We are developing Asp.Net core v2.2 .netcore Web API Application and following CI in our company. 我们正在开发Asp.Net核心v2.2 .netcore Web API应用程序,并遵循我们公司中的CI。

We have tried below code in Cake Script but facing below error while compilation. 我们已经尝试过在Cake Script中使用以下代码,但是在编译时会遇到以下错误。

Error: 错误:

error NETSDK1045: The current .NET SDK does not support targeting .NET Core 2.2. 错误NETSDK1045:当前.NET SDK不支持定位.NET Core 2.2。 Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2 目标.NET Core 2.1或更低版本,或者使用支持.NET Core 2.2的.NET SDK版本。

Cake Script: 蛋糕脚本:

Task("Build")   
    .IsDependentOn("Clean")
    .IsDependentOn("Restore")
    .Does(() => {   
    try {
       MSBuild(solutionFile , settings => settings.SetConfiguration(configuration));
       }    
    catch(Exception ex) {        
        throw new Exception(String.Format("Please fix the project compilation failures"));  
    }
    });

Cake Version : 0.23.0 蛋糕版本 :0.23.0

How to set the -framework property value .netcoreapp2.2 in Msbuild Action or anyother method to compile this ? 如何在Msbuild Action或任何其他方法中设置-framework属性值.netcoreapp2.2进行编译?

In order to take Cake out of the question, can I suggest that you run the above Cake Script with Diagnostic verbosity enabled. 为了使Cake成为可能,我是否建议您在启用Diagnostic verbosity的情况下运行上述Cake脚本。 See here for information on how to do this: 有关如何执行此操作的信息,请参见此处:

How to enable diagnostic verbosity for Cake 如何为Cake启用诊断详细程度

This will then show you the command that Cake is executing which is resulting in this error. 然后,这将向您显示Cake正在执行的命令,从而导致此错误。 Take this command and run it directly from the command line, and you should get the same result. 接受此命令并直接从命令行运行它,您应该得到相同的结果。

Now that we have ruled Cake out as causing the problem, we need to fix the underlying issue, and in this case, I think the error message is telling you exactly what the problem is, ie you don't have the correct .Net SDK installed on your machine. 现在我们已经排除了Cake导致问题的可能性,我们需要修复根本的问题,在这种情况下,我认为错误消息可以告诉您问题的确切原因,即您没有正确的.Net SDK。安装在您的计算机上。 I suspect you are going to need to install a newer version. 我怀疑您将需要安装更新的版本。

Upgraded Cake to 0.32.0 and run the below code. 将Cake升级到0.32.0并运行以下代码。

MSBuild(solutionFile , new MSBuildSettings {
    Verbosity = Verbosity.Minimal,
    ToolVersion = MSBuildToolVersion.VS2019,
    Configuration = "Release",
    PlatformTarget = PlatformTarget.MSIL
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM