Arguments And Environment Variables

How you can pass settings to build.cake.

Passing And Reading Arguments

Call the Argument alias in your Cake file to read arguments from the command line.

Example

Build script:

Argument<bool>("showstuff", false);

Execution:

dotnet cake --showstuff=true

dotnet Cake.Frosting.dll --showstuff=true

Cake.exe --showstuff=true

Cake.exe --showstuff=true

The conversion uses type converters under the hood to convert the string value to the desired type.

Reading Environment Variables

Call the Environment variables alias alias in your Cake file to get the environment variable.

The following example will read the value of the BUILD_NUMBER environment variable or return 42 if the environment variable is not defined:

Information(EnvironmentVariable<int>("BUILD_NUMBER", 42));