M.Y. Babt
M.Y. Babt

Reputation: 2891

CAKE throws error claiming argument was not set, even though it was

I am using Cake 0.21.1.0.

For my project, as a build step on TeamCity, I execute build.ps1, which in turn invokes build.cake. I pass in the following arguments to my build.ps1 script, in accordance with the CAKE documentation:

-ScriptArgs '-MSBuildLogger="JetBrains.BuildServer.MSBuildLoggers.MSBuildLogger,%teamcity.dotnet.msbuild.extensions4.0%"'

In build.cake, I added the following line:

var msBuildLogger = Argument<string>("MSBuildLogger");

However, the following error was thrown:

[15:37:22]Error: Argument 'MSBuildLogger' was not set.
[15:37:22]Process exited with code 1

What did I do wrong?

Upvotes: 2

Views: 301

Answers (1)

Gary Ewan Park
Gary Ewan Park

Reputation: 18981

Try the following build.cake file:

var logger = Argument<string>("MSBuildLogger");

Task("Default")
  .Does(() =>
{
  Information(logger);
});

RunTarget("Default");

Also, fetch the most recent bootstrapper file from the resources repository using:

Invoke-WebRequest https://cakebuild.net/download/bootstrapper/windows -OutFile build.ps1

Then run the following:

.\build.ps1 -ScriptArgs '-MSBuildLogger="JetBrains.BuildServer.MSBuildLoggers.MSBuildLogger,%teamcity.dotnet.msbuild.extensions4.0%"'

Confirm that you are getting the correct output when running the script locally. i.e. take TeamCity out of the equation.

Upvotes: 5

Related Questions