I keep on forgetting how to form the command line in PowerShell for a Cake build script with multiple command line arguments.
In Cake, command line arguments are available in the build script as shown below:
var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); var version = Argument("build_version", "1.0.0.0"); var releaseCandidate = Argument("release_candidate", "0");
As you can see, the arguments can have a default value. For example, the default target is “Default”. That looks like this in the Cake script
Task ("Default") .IsDependentOn ("BuildSolution") .IsDependentOn ("Run-Unit-Tests") .IsDependentOn ("BuildPackages");
Let’s say that we want to pass into the script the build version and a release candidate number.
.\build.ps1 -ScriptArgs "--build_version=1.0.0.12","--release_candidate=1"
In Cake. You define a default build script called “build.cake”. Cake’s main script is called build.ps1, which bootstraps Cake and runs the “build.cake” script.
The example repository will teach you everything you need to know about Cake in about 15 minutes.