10 July 2019


Cake (C# Make) is a cross-platform build automation tool which makes use of the C# language for creating tasks such as compiling code, copying files and folders, running unit tests, compressing files and building NuGet packages for .NET and .NET Core applications. Regardless if you're building on your own machine, or building on a CI system such as AppVeyor, Azure DevOps, TeamCity, TFS or Jenkins, Cake is built to behave in the same way.

Build automation and Continuous Integration

Continuous Integration (CI), is a very important part of delivering quality software. CI involves developers in a team merging their changes to a central repository continuously throughout the development cycle. As developers continue to merge code to the main branch, each merge is expected to trigger an automated build, which runs after all the automated tests have been run and ideally have passed.

The idea behind CI is to make sure that developers ship tested code with confidence. This places great emphasis on automated tests checking that the solution is not broken whenever new commits are merged into the main branch. In essence, using automated tests to catch any regression bugs earlier on in the development cycle.

Build automation

A typical build process involves calling a series of programs (tools) each with its own features, rules and syntax. What is needed, is to be a build automation tool which makes it easier to invoke external programs, passing parameters to them and gather their results in a form that can easily be consumed by other programs. We also need to handle and report any error conditions that may arise from any of those external programs in a consistent way so that we can make decisions on what to do based on that. Cake makes them all work together seamlessly to bring a system from source code to running software.

Why use Cake

There are several advantages for using Cake build automation tool:

  • Integration with build and deploy tools.
  • Increase team productivity.
  • Build scripts and configuration in repository.
  • Using the same language (C#) and platform to write build scripts.
  • Build agnostic from build server.
  • Integrates well with CI servers and decreases complexity.

  • Conclusions

    Continuous Integration tools, such as TeamCity or Jenkins are powerful and useful tools for a DevOps team. They can checkout code, build it, and deploy the software to the environment of your choice.
    Problems arise when developers overuse custom steps in the CI/CD tool instead of a build script. TeamCity makes it very convenient to put together multiple steps, pass in parameters, and create build templates. Given enough time and complexity, these steps can become an untestable “program” that is only run when the software builds and deploys.

    There are a ton of built-in tasks and the Cake documentation is really good. Removing the build steps out of the build system and turning into code has two major benefits: Build anywhere and Source Control.