0

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 ?

Gary Ewan Park
  • 17,610
  • 5
  • 42
  • 60
vijay
  • 701
  • 2
  • 12
  • 26
  • This is not a question. This is business requirement. You should research, try to do something then if you have any particular code problem, you can ask. But where is the code? I don't see any. – jazb Aug 02 '19 at 05:58

2 Answers2

1

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.

Gary Ewan Park
  • 17,610
  • 5
  • 42
  • 60
  • My project is compiling fine in VS2019 as well as command line by using latest msbuild 16.0 but in cake script msbuild using 15.0. – vijay Aug 08 '19 at 08:53
  • So my point is the same... Check to see the exact command that is coming from Cake to run MSBuild, compare to what you know works, and then we can figure out what you need to change. – Gary Ewan Park Aug 08 '19 at 08:55
  • Thanks Gep , Posted my answer https://cakebuild.net/api/Cake.Common.Tools.MSBuild/MSBuildAliases/C240F0FB – vijay Aug 08 '19 at 08:58
0

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
    });
vijay
  • 701
  • 2
  • 12
  • 26