vijay
vijay

Reputation: 791

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.

We have tried below code in Cake Script but facing below error while compilation.

Error:

error NETSDK1045: The current .NET SDK does not support targeting .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

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

How to set the -framework property value .netcoreapp2.2 in Msbuild Action or anyother method to compile this ?

Upvotes: 0

Views: 204

Answers (2)

vijay
vijay

Reputation: 791

Upgraded Cake to 0.32.0 and run the below code.

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

Upvotes: 0

Gary Ewan Park
Gary Ewan Park

Reputation: 18981

In order to take Cake out of the question, can I suggest that you run the above Cake Script with Diagnostic verbosity enabled. See here for information on how to do this:

How to enable diagnostic verbosity for Cake

This will then show you the command that Cake is executing which is resulting in this error. 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, i.e. you don't have the correct .Net SDK installed on your machine. I suspect you are going to need to install a newer version.

Upvotes: 1

Related Questions