The Sweetness of Cake & .NET Core

As with any university project I undertake I like to take the time to mess around with tools, frameworks and languages I’m not incredibly familiar with. It’s a nice way to learn a new trick or skill to add to the portfolio and especially in larger group projects it can be a good indication of how viable what you’re doing would be in the workplace.

One tool I’ve seen floating around the “.NET Space” (not the worst thing I’ve written but definitely up there) is Cake (C# Make).

Cake’s website reads…

Cake (C# Make) is a cross platform build automation system with a C# DSL to do things like compiling code, copy files/folders, running unit tests, compress files and build NuGet packages

Whilst in practice this doesn’t sound too fun, working with the system itself has been a blast so far. It is easy to configure, simple to work with and out of the box is jam packed full of functionality. I think the biggest part of why Cake has been such a joy to use is how well it is integrated with the runtime.

Getting started with Cake is simple, all your major pieces of functionality provided in a single shell script. This script is available for both PowerShell and Bash, running a build using Cake is as easy as executing the script. Once you have the required script, you get to the fun part; writing the Cake Script.

The build.cake file is where you define your build tasks, the order they are executed in and any other related build logic such as providing conditions for when a build fails or succeeds. Like with other build automation tools such as Ant, you define tasks in Cake which are executed and depended upon each other. This concept of dependency provides a large amount of the flow of a build, the order of tasks defined by when and if they are needed.

What makes Cake cool is rather than defining your builds in using something like XML you write your build scripts in C#. This to me is the coolest part of Cake, my project and its build script written in the same language.

Cake’s Documentation is great too, despite it being such a Swiss Army Knife for .NET Developers the tutorials are focused and provide a good way to get started using the system. You quickly learn that you define your steps using the Task function, giving the tasks dependent tasks with the IsDependentOn and finally providing what the task Does with a simple lambda function. Assuming we’re just building a simple C# solution, the Cake Script could be as slim as the following.

I guess that brings us back as to why Cake works so well with .NET Core, out of the box Cake provides methods for building, running and testing; basically anything you’d need to do from the CLI you can achieve in cake.

So I’d say for anything in future you do in .NET consider using Cake for your build automation. After all even with my word aside, 1,000,000 downloads is a pretty convincing reason to give it a go.

Edit #1: Thanks to Matthias for correcting my incredibly flawed conclusion :)




Melbourne based software dev, loves .NET, Typescript and Azure. Master of pretending to know what I'm talking about

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alex Billson

Alex Billson

Melbourne based software dev, loves .NET, Typescript and Azure. Master of pretending to know what I'm talking about

More from Medium

How Asp .NET Request Process till Page Life Cycle Start.

Generics in C#

The Facilis framework for dotnet core — the repository

Use ASP.NET Core hosted services to run a background task