3

I seem to be unable to persuade Cake to build my .Net core project in Debug configuration.

At the moment I have this:

void BuildProject(string projectPath, string configuration)
{
    var settings = new DotNetCoreBuildSettings();
    settings.Configuration = "Debug";

    DotNetCoreBuild(projectPath, settings);
}

...

Task("Build")
   .IsDependentOn("RestorePackages")
   .Does(() => 
   {
       BuildProject("src/DlnaCore.Server/DlnaCore.csproj", configuration);
   });

which just builds the release config.

Having scoured what I can find in the docs I cannot seem to find the correct incantation :-/

Stewart_R
  • 13,764
  • 11
  • 60
  • 106
  • If you run the build with Diagnostic Verbosity, what `dotnet` command is actually emitted from Cake (https://stackoverflow.com/questions/38658660/how-to-enable-diagnostic-verbosity-for-cake) – Gary Ewan Park Aug 02 '17 at 07:07
  • @GaryEwanPark This confirms that it is actually building in Release: `Executing: "C:/Program Files/dotnet/dotnet.exe" build "src/DlnaCore.Server/DlnaCore.csproj" --configuration Release` – Stewart_R Aug 02 '17 at 07:56
  • Can you also confirm what version of Cake you are using? – Gary Ewan Park Aug 02 '17 at 08:02
  • Version 0.21.1+Branch.main.Sha.9ff85bb53ea1890fabeb709d38ba79d3bf5cb16f – Stewart_R Aug 02 '17 at 08:10
  • Can you try clearing out your local tools folder, and trying again? This is the only thing I can think of. I have just tried the above code that you have posted, and the expected command is emitted from Cake, i.e. `Executing: "C:/Program Files/dotnet/dotnet.exe" build "src/DlnaCore.Server/DlnaCore.csproj" --configuration bob` where I obviously changed `Debug` to `bob` within `BuildProject`. – Gary Ewan Park Aug 02 '17 at 08:16
  • You should build the solution instead of the project directly. – Patrik Svensson Aug 02 '17 at 08:58
  • @Patrik - not sure that should make any difference? Is there a reason for suggesting that? As it stands I don't even have a solution file. – Stewart_R Aug 02 '17 at 09:01
  • Not sure, but information about the configurations are normally stored in the solution file. I've had a lot of problems building projects directly with the new dotnet MSBuild tooling. – Patrik Svensson Aug 02 '17 at 09:03
  • @Patrik I don't think that's the issue for me. I can enter the `dotnet build --configuration "Debug"` command myself and get the results I need. – Stewart_R Aug 02 '17 at 09:07
  • @Stewart_R I see. I have no clue then. I use Cake to build projects with Release configuration with the latest tooling and it works for me. Best bet would be to try to reproduce this and post an issue at github.com/cake-build/cake – Patrik Svensson Aug 02 '17 at 09:13
  • 1
    Can you post more of your build script, maybe there is an issue there. I'm just guessing because of the unused `configuration` parameter in your current sample. What command line parameters do you use to call cake? – Philipp Grathwohl Aug 02 '17 at 09:22
  • The reason for suggesting it was to ensure that you actually have the latest Cake in the tools folder. Assuming you are using a packages.config file to restore the Cake version, if you already had a previous version restored to the tools folder, it may not have overridden with the latest version. – Gary Ewan Park Aug 02 '17 at 09:29
  • Did you get this work in the end? – Gary Ewan Park Aug 07 '17 at 20:03
  • I did. I had made a bit of a catalogue of errors... The above would work were it not for the other mistakes. What's the SO protocol when one makes a pigs ear of the question? Apologise and delete it? Leave it there for others? Either way I really appreciate everyone's kind help & suggestions. Sorry for being a wally :-/ – Stewart_R Aug 07 '17 at 20:25

0 Answers0