Cake .NET Tool is a runner which allows to run Cake scripts.
See Setting Up A New Cake .NET Tool Project tutorial for how to get started with Cake .NET Tool.
Requirements
The Cake.Tool NuGet package, is a .NET tool compiled for .NET 8 or newer.
Usage
dotnet cake [script] [switches]
Switches
Switch | Description | Available Since |
---|---|---|
--bootstrap | Download/install modules defined by #module directives, but do not run build. Since 1.0.0-rc0001 bootstrapping is done by default when running build. |
0.24.0 |
-d, --debug | Launches script in debug mode. | 0.12.0 |
--description | Shows description about tasks. | 0.1.10 |
--dryrun | Performs a dry run. | 0.2.0 |
-e, --exclusive | Execute a single task without any dependencies. | 0.29.0 |
-h, --help | Prints help information. | 0.1.12 |
--info | Displays additional information about Cake execution. | 0.31.0 |
--skip-bootstrap | Skips bootstrapping when running build. | 1.0.0-rc0001 |
--tree | Shows the task dependency tree. | 0.31.0 |
-v, --verbosity <VERBOSITY> | Specifies the amount of information to be displayed (quiet, minimal, normal, verbose, diagnostic). | 0.1.1 |
--version | Displays version information. | 0.1.12 |
--target=<target>
is not a switch of the runner, but a custom switch which scripts often implement to invoke a specific task.
Custom switches
All switches not recognized by Cake will be added to an argument list that is passed to the build script. See Arguments And Environment Variables how to read arguments in your script.
Use a space instead of =
if the value of a switch can be empty or null:
--foo ""
Bootstrapping for .NET Tool
Bootstrapping scripts ensure you have Cake and other required dependencies installed. The bootstrapper scripts are also responsible for invoking Cake.
The following instructions require .NET 8.0 or newer. See How to manage .NET Core tools for details and other options.
Setup
There's a one-time setup required for configuring a repository to use Cake .NET tool.
If you have .NET Tool already available in your environment you can skip the steps in this chapter.
Make sure to have a tool manifest available in your repository or create one using the following command:
dotnet new tool-manifest
Install Cake as a local tool using the dotnet tool
command:
dotnet tool install Cake.Tool --version 5.0.0
You can replace 5.0.0
with a different version of Cake you want to use.
Getting the bootstrapper
Use of a bootstrapper is optional. You can also directly call the .NET CLI if you prefer.
A Bootstrapper for Cake .NET Tool is available in the Cake Resources repository and can be installed using the command for your operating system from below:
Open a new PowerShell window and run the following command:
Invoke-WebRequest https://cakebuild.net/download/bootstrapper/dotnet-tool/windows -OutFile build.ps1
Sometimes PowerShell might prevent you from running build.ps1
.
Make sure to have RemoteSigned
policy enabled.
See About Execution Policies for details.
If you have RemoteSigned
policy enabled and still an error occurrs it might be because
the file was downloaded from the internet and is blocked.
The following command will unblock the file:
Unblock-File path\to\build.ps1
See Unblock-File for details.
Open a new shell and run the following command:
curl -Lsfo build.sh https://cakebuild.net/download/bootstrapper/dotnet-tool/linux
If you are downloading the build.sh
file on a Windows machine you can give the script permission to execute using the following command:
git update-index --add --chmod=+x build.sh
This assumes that you have the Git command line installed.
Open a new shell and run the following command:
curl -Lsfo build.sh https://cakebuild.net/download/bootstrapper/dotnet-tool/osx
If you are downloading the build.sh
file on a Windows machine you can give the script permission to execute using the following command:
git update-index --add --chmod=+x build.sh
This assumes that you have the Git command line installed.
Running build script
To launch Cake run the bootstrapper:
Open a new PowerShell window and run the following command:
./build.ps1
Open a new shell and run the following command:
build.sh
Open a new shell and run the following command:
build.sh
By convention this will execute the build script named build.cake
.
You can override this behavior by additionally passing the name of the build script.
Extending the bootstrapper
The bootstrapper that you can get directly from cakebuild.net is intended as a starting point for what can be done. It is the developer's discretion to extend the bootstrapper to solve for your own requirements.
Using pre-release versions
Cake uses Azure Artifacts as a NuGet feed for testing and pre-release builds. With these pre-release builds the next version of Cake can be accessed and utilized for getting the latest features or testing addins or build scripts to know if the next release will be safe when you need to upgrade.