Difficulty: beginner
Estimated Time: 5-10 minutes

Welcome to an Introduction on how to use the Cake Build system.

This course makes use of a katacoda base image which already have Cake installed, and ready to use. As a result, the steps that you will see within this course are likely going to be slightly different to others that you might have seen, since the typical bootstrapper script is not required.

i.e. rather than running:

.\build.ps1

or

./build.sh

You can simply run cake to initiate the build script.

However, everything else should be exactly the same. Let's get started.

You've completed your first Cake scenario!

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Cake Introduction

Step 1 of 3

Step 1 - Create Build Script

In order to get started with Cake, you are going to need a build script. This is typically called build.cake (and this is what Cake looks for by default when no script name is provided), but you can call it whatever you want. You should find a build.cake file already to go.

Task

Let's create a typical build.cake file. Copy the below into the build.cake file, and click the cake button.

var target = Argument("target", "FirstTask");

Task("FirstTask")
    .Does(()=>
    {
        Information("Hello World!");
    });

RunTarget(target);

cake

What is this doing?

On the first line we are using a built in alias to grab a command line argument passed into Cake. When there is no argument passed, a default value of Hello is used.

We then define a Task to actually do some work. This task is named FirstTask and simply uses the Information alias to write out "Hello from Cake" to the command line.

The `RunTarget method is then called to execute the defined target, which by default, will be the Hello task.

The output from Cake will then show which Tasks were executed, how long they took, and whether the build was successful or not.