A stand-alone .NET Core runner and host for Cake.
C# PowerShell



AppVeyor branch MyGet

A .NET Core host for Cake, that allows you to write your build scripts as a portable console application (netstandard1.0). Frosting is currently in alpha, but more information, documentation and samples will be added soon.

Expect things to move around initially. Especially naming of things.

Table of Contents

  1. Example
  2. Acknowledgement
  3. License
  4. Thanks
  5. Code of Conduct
  6. .NET Foundation


1. Add nuget.config

Start by adding a nuget.config file to your project.
The reason for this is that Cake.Frosting is in preview at the moment and not available on nuget.org.

    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="myget.org" value="https://www.myget.org/F/cake/api/v3/index.json" protocolVersion="3" />

2. Add project.json

Now create a project.json file that will tell dotnet what dependencies are required to build our program. The Cake.Frosting package will decide what version of Cake.Core and Cake.Common you will get.

  "version": "0.1.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  "dependencies": {
    "Cake.Frosting": "0.1.0-alpha0034",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
  "tools": {
    "Cake.Frosting.CLI": "0.1.0-alpha0034"

3. Add Program.cs

For the sake of keeping the example simple, all classes are listed after each other, but you should of course treat the source code of your build scripts like any other code and divide them up in individual files.

using Cake.Common.Diagnostics;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Frosting;

public class Program
    public static int Main(string[] args)
        // Create the host.
        var host = new CakeHostBuilder()
            .ConfigureServices(services =>
                // Use a custom settings class.

                // Use a custom lifetime to initialize the context.

                // Use the parent directory as the working directory.

        // Run the host.
        return host.Run();

public class MySettings : FrostingContext
    public bool Magic { get; set; }

    public MySettings(ICakeContext context)
        : base(context)
        // You could initialize the context here,
        // but it's recommended to use a FrostingLifetime
        // since the context will be created when running
        // a dry run of the script as well.

public class MyLifetime : FrostingLifetime<MySettings>
    public override void Setup(MySettings context)
        context.Magic = context.Arguments.HasArgument("magic");

public class Build : FrostingTask<MySettings>
    public override bool ShouldRun(MySettings context)
        // Don't run this task on OSX.
        return context.Environment.Platform.Family != PlatformFamily.OSX;

    public override void Run(MySettings context)
        context.Information("Magic: {0}", context.Magic);

public class Default : FrostingTask
    // If you don't inherit from FrostinTask<MySettings>
    // the standard ICakeContext will be provided.

4. Run it!

To execute the build, simply run it like any .NET Core application.
In the example we provide the custom --magic argument. Notice that we use -- to separate the arguments to the dotnet command.

> dotnet restore
> dotnet run -- --magic

Or, if you want to use the .NET CLI tool, you can run your build using the following commands.

> dotnet restore
> dotnet cake --magic


The API for configuring and running the host have been heavily influenced by the ASP.NET Core hosting API.


Copyright © .NET Foundation and contributors.
Frosting is provided as-is under the MIT license. For more information see LICENSE.


A big thank you has to go to JetBrains who provide each of the Cake developers with an Open Source License for ReSharper that helps with the development of Cake.

The Cake Team would also like to say thank you to the guys at MyGet for their support in providing a Professional subscription which allows us to continue to push all of our pre-release editions of Cake NuGet packages for early consumption by the Cake community.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.