Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
125 lines (96 sloc) 4.42 KB

Order: 10

This is a guide to get started with Cake and to show you how Cake works.

1. Clone the example repo

First, clone the example repository or download the latest zip. This repository contains a simple project and all files necessary to run the cake script.

NOTE: If downloading the latest zip file, ensure that it is unblocked otherwise you will run into issues when attempting to execute Cake.

Files of interest

You need three files for a build (these will be the only files you need to commit to your repo to use Cake, see how to pinning cake version for further guidance.):

  • build.ps1 and
    • These are bootstrapper scripts that ensure you have Cake and other required dependencies installed. The bootstrapper scripts are also responsible for invoking Cake. These files are optional, and not a hard requirement. If you would prefer not to use these scripts you can invoke Cake directly from the command line, once you have downloaded and extracted it.
  • build.cake
    • This is the actual build script. It doesn't have to be named this but this will be found by default.
  • tools/packages.config
    • This is the package configuration that tells the bootstrapper script what NuGet packages to install in the tools folder. An example of this is Cake itself or additional tools such as unit test runners, ILMerge etc.

2. Run the build script

Open up a Powershell prompt and execute the bootstrapper script:

PS> .\build.ps1

The script will detect that you don't have Cake and automatically download it from NuGet.

It will then run the very simple build.cake script that will clean up the output directory, restore all NuGet packages and build the project.

Congratulations, you've run your first Cake script!

NOTE: If you are running Cake on a 32 bit Operating System, you will need to provide an additional parameter to ensure that the build script runs correctly. This is due to an issue with Roslyn. Either use:

PS> .\cake\cake.exe build.cake -mono


PS> .\cake\cake.exe build.cake -experimental

If you are using the bootstrapper build.ps1 file, you will need to modify the calling of the Cake.exe to include this parameter as well.

3. Bonus points!

The script is a fairly bare-bones implementation. But extending it is easy.

For instance to run the extensive unit tests for the awesome application you need to add a test target:

    .Does(() =>
    NUnit("./src/**/bin/" + configuration + "/*.Tests.dll");

This is using NUnit out of the box but you have MSTest and xUnit test helpers as well.

Adding the target doesn't necessarily run it unless another target is dependent on it or you call it explicitly. In our case we can just change the default task to be dependent on our test task (which in turn is dependent on the build task):


Execute the build script again (as we did before), and the script will run all the tests as expected.


This tutorial was adapted from Mark's excellent Cake tutorial that's available at

You can’t perform that action at this time.