### Install GitVersion.Tool using InstallTool Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sdk/tools.md Installs the GitVersion.Tool package from a specified NuGet source. This example also demonstrates retrieving the version information after installation. ```csharp #:sdk Cake.Sdk var target = Argument("target", "Pack"); Setup(context => { InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=6.3.0"); var version = GitVersion(); Information("Building Version: {0}", version.FullSemVer); }); ``` -------------------------------- ### Install tool using InstallTool in Cake Frosting Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/tools/installing-tools.md For Cake Frosting, use the InstallTool method within the IFrostingStartup to download and install a NuGet package. This example installs the xunit.runner.console package. ```csharp public class Program : IFrostingStartup { public static int Main(string[] args) { // Create and run the host. return new CakeHost() .InstallTool(new Uri("nuget:?package=xunit.runner.console&version=2.4.1")) .Run(args); } } ``` -------------------------------- ### Install tool using InstallTool in Cake.Sdk Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/tools/installing-tools.md Cake.Sdk uses the InstallTool method within the Setup configuration to download and install tools. This example installs the GitVersion.Tool package. ```csharp #:sdk Cake.Sdk Setup(context => { InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=6.3.0"); var version = GitVersion(); Information("Building Version: {0}", version.FullSemVer); }); ``` -------------------------------- ### RWX CI Configuration Example Source: https://github.com/cake-build/website/blob/master/input/blog/2026-05-22-cake-v6.2.0-released.md An example RWX YAML configuration demonstrating how to set up a build environment, install .NET SDK, and invoke Cake using Cake.Sdk, Cake .NET Tool, and Cake Frosting. ```yaml on: github: pull_request: init: commit-sha: ${{ event.git.sha }} push: - if: ${{ event.git.branch == 'develop' || event.git.branch == 'main' || starts-with(event.git.branch, 'hotfix/') }} init: commit-sha: ${{ event.git.sha }} cli: init: commit-sha: ${{ event.git.sha }} base: image: ubuntu:26.04 config: rwx/base 1.1.1 tasks: - key: code call: git/clone 2.0.7 with: repository: https://github.com/your-org/your-repo.git ref: ${{ init.commit-sha }} fetch-full-depth: true preserve-git-dir: true - key: install-dotnet use: code call: dotnet/install 1.0.0 with: global-json-file: global.json filter: - global.json - key: build use: [code, install-dotnet] run: | # Cake Sdk dotnet cake.cs # Cake Tool dotnet tool restore dotnet cake # Cake Frosting dotnet run --project cake.csproj ``` -------------------------------- ### Install Addin by Package Name Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/addin.md This example shows the basic syntax for specifying only the package name, allowing NuGet to resolve the version. ```csharp #addin nuget:?package=Cake.Foo ``` -------------------------------- ### Return Typed Context from Setup Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sharing-build-state.md Configure the Setup method to return an instance of your typed context class. This allows tasks to access the initialized state. The example demonstrates setting properties based on build arguments and environment. ```csharp Setup(setupContext => { return new BuildData( configuration: Argument("configuration", "Release"), buildPackages: !BuildSystem.IsLocalBuild ) { Frameworks = IsRunningOnUnix( ? new List { "netcoreapp2.1" } : new List { "net472", "netcoreapp2.1" } }; }); ``` -------------------------------- ### Install and Run EF Version using Command Alias (Cake.Sdk) Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/tools/running-tools.md Execute the `ef --version` command using the `Command` alias after installing the `dotnet-ef` tool via `InstallTool` in a Cake.Sdk setup. ```csharp #:sdk Cake.Sdk@6.1.1 Setup(context => { InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=dotnet-ef&version=8.0.0"); }); Task("Ef-Version") .Does(() => { Command( new[] { "dotnet", "dotnet.exe" }, "ef --version" ); }); ``` -------------------------------- ### Install Cake.Template Package Source: https://github.com/cake-build/website/blob/master/input/blog/2025-08-13-cake-sdk-net-preview-7-update.md Install the Cake.Template package using the dotnet CLI to get started with Cake projects. Specify the version to ensure you are using the latest preview. ```bash dotnet new install Cake.Template@5.0.25225.53-beta ``` -------------------------------- ### Multi-file Build Script Configuration Source: https://github.com/cake-build/website/blob/master/input/blog/2025-07-17-dotnet-cake-cs.md Example of `cake.cs` in a multi-file setup, using MSBuild properties to include/exclude additional files. ```csharp #:sdk Cake.Sdk #:property IncludeAdditionalFiles=build/**/*.cs #:property ExcludeAdditionalFiles=build/**/Except*.cs ``` -------------------------------- ### Cake Setup Definition Template Source: https://github.com/cake-build/website/blob/master/input/docs/integrations/editors/rider/templates.md Provides a sample setup definition for a Cake build script. ```csharp Setup(context => { Information("Setting up the build..."); // Initialize your build environment here }); ``` -------------------------------- ### Documenting a Method with Summary, Params, Returns, and Example Source: https://github.com/cake-build/website/blob/master/input/community/contributing/documentation.md Document methods using summary, param, returns tags, and provide usage examples with the example and code tags. Categorize using CakeAliasCategoryAttribute. This example demonstrates documenting the MakeAbsolute method. ```csharp /// /// Makes the path absolute (if relative) using the current working directory. /// /// /// /// var path = MakeAbsolute(Directory("./resources")); /// /// /// The context. /// The path. /// An absolute directory path. [CakeMethodAlias] [CakeAliasCategory("Path")] public static DirectoryPath MakeAbsolute(this ICakeContext context, DirectoryPath path) {...} ``` -------------------------------- ### Install Tool using Nuget Scheme Source: https://github.com/cake-build/website/blob/master/input/blog/2025-07-17-dotnet-cake-cs.md Installs a tool from a NuGet repository using the 'nuget:' scheme. ```csharp InstallTool("nuget:?package=xunit.runner.console&version=2.4.1"); ``` -------------------------------- ### Install Addin from Local Directory Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/addin.md Addins can also be installed from a local directory using the `file://` URI scheme. ```csharp #addin nuget:file://C:/MyPackages/?package=Cake.Foo ``` -------------------------------- ### Install Cake.Bakery via Chocolatey Source: https://github.com/cake-build/website/blob/master/input/docs/integrations/editors/vscode/intellisense.md Use this command to install Cake.Bakery on Windows via Chocolatey. ```cmd choco install cake-bakery.portable ``` -------------------------------- ### Install Cake.Bakery Globally with NuGet Source: https://github.com/cake-build/website/blob/master/input/blog/2018-02-21-intellisense-improvements.md Use this command to install Cake.Bakery globally. Replace `` with your desired installation directory. ```bash nuget.exe install Cake.Bakery -OutputDirectory -ExcludeVersion ``` -------------------------------- ### Install Tool with Cake Frosting 1.0 Source: https://github.com/cake-build/website/blob/master/input/docs/getting-started/upgrade.md Cake Frosting 1.0 simplifies tool installation by renaming `UseTool` to `InstallTool` and integrating host creation and running. ```csharp public class Program : IFrostingStartup { public static int Main(string[] args) { // Create and run the host. return new CakeHost() .InstallTool(new Uri("nuget:?package=NUnit.ConsoleRunner&version=3.11.1")); .Run(args); } } ``` -------------------------------- ### Return typed context from Setup method Source: https://github.com/cake-build/website/blob/master/input/blog/2018-05-31-cake-v0.28.0-released.md Instantiate and return your custom context class from the Setup method, passing configuration arguments and build system information. ```csharp Setup(setupContext => { return new MyBuildData( configuration: Argument("configuration", "Release"), signAssemblies: BuildSystem.IsRunningOnAppVeyor); }); ``` -------------------------------- ### Create File-based Cake Project with Example Source: https://github.com/cake-build/website/blob/master/input/docs/running-builds/runners/cake-sdk.md Generate a file-based Cake project with example code for cleaning, building, and testing. ```bash dotnet new cakefile --name cake --IncludeExampleProject true ``` -------------------------------- ### Install Tool from Local Directory Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/tool/nuget-provider.md Installs a tool package from a local directory path. Ensure the path is correctly formatted and accessible. ```csharp #tool nuget:file://localhost/packages/?package=Cake.Foo ``` -------------------------------- ### Install Cake.Template Package Source: https://github.com/cake-build/website/blob/master/input/blog/2025-07-17-dotnet-cake-cs.md Use this command to install the Cake.Template package, which provides templates for various Cake scenarios. ```bash dotnet new install Cake.Template@5.0.25198.49-beta ``` -------------------------------- ### Install Addin from NuGet Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/addin.md Use the `#addin` directive to install and reference addins from NuGet. This is the basic syntax for adding a package. ```csharp #addin nuget:?package=Cake.Foo&version=1.0.0 ``` -------------------------------- ### Install Prerelease Addin Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/addin.md To install prerelease versions of an addin without specifying a full version number, use the `prerelease` parameter. ```csharp #addin nuget:?package=Cake.Foo&prerelease ``` -------------------------------- ### Install Multiple Tools using Dotnet Scheme Source: https://github.com/cake-build/website/blob/master/input/blog/2025-07-17-dotnet-cake-cs.md Installs multiple tools from NuGet repositories using the 'dotnet:' scheme. ```csharp InstallTools( "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.12.0", "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.20.0" ); ``` -------------------------------- ### Minimal Cake.Sdk Example Source: https://github.com/cake-build/website/blob/master/input/blog/2025-07-17-dotnet-cake-cs.md This is the most basic example of using Cake.Sdk in a file-based script. It requires the `#:sdk Cake.Sdk` directive. ```csharp #:sdk Cake.Sdk Information("Hello world!"); ``` ```bash dotnet cake.cs ``` -------------------------------- ### Install Cake.Template Package Source: https://github.com/cake-build/website/blob/master/input/docs/running-builds/runners/cake-sdk.md Install the Cake.Template package globally to use Cake project templates. ```bash dotnet new install Cake.Template ``` -------------------------------- ### Install Addin from MyGet Feed Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/addin.md To install an addin from a feed other than the default nuget.org, specify the feed URL. ```csharp #addin nuget:https://myget.org/f/Cake/?package=Cake.Foo ``` -------------------------------- ### Install Cake.Core NuGet Package Source: https://github.com/cake-build/website/blob/master/input/docs/extending/addins/creating-addins.md Install the Cake.Core NuGet package using the Package Manager Console. ```powershell PM> Install-Package Cake.Core ``` -------------------------------- ### Install Single Tool using Dotnet Scheme Source: https://github.com/cake-build/website/blob/master/input/blog/2025-07-17-dotnet-cake-cs.md Installs a single tool from a NuGet repository using the 'dotnet:' scheme. ```csharp InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.12.0"); ``` -------------------------------- ### Install Tool with Cake Frosting 0.38.x Source: https://github.com/cake-build/website/blob/master/input/docs/getting-started/upgrade.md In Cake Frosting 0.38.x, you needed to manually register the NuGet module and use `UseTool` to install packages. ```csharp public class Program : IFrostingStartup { public static int Main(string[] args) { // Create the host. var host = new CakeHostBuilder() .WithArguments(args) .UseStartup() .Build(); // Run the host. return host.Run(); } public void Configure(ICakeServices services) { // Register the NuGet module. var module = new NuGetModule(new CakeConfiguration(new Dictionary())); module.Register(services); // Register tools. services.UseTool(new Uri("nuget:?package=NUnit.ConsoleRunner&version=3.11.1")); } } ``` -------------------------------- ### Install Cake.Tool Globally Source: https://github.com/cake-build/website/blob/master/input/blog/2019-09-28-cake-v0.35.0-released.md Installs the Cake.Tool globally using the specified version. Ensure Cake.Tool is in your PATH. ```bash dotnet tool install --global Cake.Tool --version 0.35.0 ``` -------------------------------- ### Utilities file example Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sdk/preprocessor-directives/additional-files.md An example of a utilities file (build/Utilities.cs) for a multi-file Cake application. This file contains a static LogInfo method. ```csharp public static partial class Program { public static void LogInfo(string message) { Information($"INFO: {message}"); } } ``` -------------------------------- ### Install Cake .NET Tool Source: https://github.com/cake-build/website/blob/master/input/docs/getting-started/setting-up-a-new-scripting-project.md Install Cake as a local tool using the `dotnet tool` command. Replace `` with the desired Cake version. ```powershell dotnet tool install Cake.Tool --version ``` -------------------------------- ### Install xunit.runner.console using NuGet provider Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sdk/tools.md Installs the xunit.runner.console package using the 'nuget:' provider. Ensure the package and version are correctly specified. ```csharp Setup(context => { InstallTool("nuget:?package=xunit.runner.console&version=2.4.1"); }); ``` -------------------------------- ### Install Cake using Chocolatey Source: https://github.com/cake-build/website/blob/master/input/blog/2015-12-03-cake-v0.6.1-released.md Install Cake globally on your workstation using the Chocolatey package manager. ```bash choco install cake.portable ``` -------------------------------- ### Install Cake.Tool with .NET Tool Source: https://github.com/cake-build/website/blob/master/input/blog/2021-11-07-cake-v2.0.0-rc0001-released.md Use these commands to install the Cake.Tool locally for testing. This ensures Cake is only available within the current folder, preventing interference with other projects. ```bash dotnet new tool-manifest dotnet tool install Cake.Tool --version 2.0.0-rc0001 ``` -------------------------------- ### Install Cake Frosting Template Source: https://github.com/cake-build/website/blob/master/input/docs/getting-started/setting-up-a-new-frosting-project.md Installs the Cake Frosting project template. This command is required before creating a new Frosting project. ```powershell dotnet new install Cake.Frosting.Template ``` -------------------------------- ### C# 8 Example Output Source: https://github.com/cake-build/website/blob/master/input/blog/2019-09-28-cake-v0.35.0-released.md The expected output when running the C# 8 example code, showing the formatted verbosity levels. ```bash [* ] = Minimal [** ] = Normal [*** ] = Verbose [****] = Diagnostic ``` -------------------------------- ### Run NuGet Help using StartProcess Alias Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/tools/running-tools.md Execute `nuget help install` with full control over process settings using the `StartProcess` alias, resolving the `nuget.exe` path via `Context.Tools.Resolve`. ```csharp Task("NuGet-Help") .Does(() => { var nugetPath = Context.Tools.Resolve("nuget.exe"); StartProcess(nugetPath, new ProcessSettings { Arguments = new ProcessArgumentBuilder() .Append("help") .Append("install") }); }); ``` -------------------------------- ### Global Lifetime Setup and Teardown for Cake Frosting Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/setup-and-teardown.md Implement IFrostingLife by inheriting FrostingLifetime or FrostingLifetime to control global setup and teardown. Register with UseLifetime. ```csharp public static class Program { public static int Main(string[] args) { return new CakeHost() .UseContext() .UseLifetime() .Run(args); } } public class BuildLifetime : FrostingLifetime { public override void Setup(BuildContext context, ISetupContext info) { // Executed BEFORE the first task. } public override void Teardown(BuildContext context, ITeardownContext info) { // Executed AFTER the last task. } } ``` -------------------------------- ### Recursive File Globbing Example Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/globbing-patterns.md Example of recursively getting all files with a .cs extension. ```csharp var files = GetFiles("./**/*.cs"); ``` -------------------------------- ### Install and Run EF Version using Command Alias (.NET Tool) Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/tools/running-tools.md Download the `dotnet-ef` tool into the build's tool cache using the `#tool` directive, then execute `ef --version` via the `Command` alias. ```csharp #tool dotnet:?package=dotnet-ef&version=8.0.0 Task("Ef-Version") .Does(() => { Command( new[] { "dotnet", "dotnet.exe" }, "ef --version" ); }); ``` -------------------------------- ### Create Cake Project with Example Solution Source: https://github.com/cake-build/website/blob/master/input/blog/2025-08-13-cake-sdk-net-preview-7-update.md Generate a Cake file-based project that includes an example solution file. Use the --force flag if overwriting existing files. ```bash dotnet new cakefile --name cake --IncludeExampleProject true --force ``` -------------------------------- ### Recursive Directory Globbing Example Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/globbing-patterns.md Example of recursively getting all directories named 'bin' within the 'src' folder. ```csharp var directories = GetDirectories("./src/**/bin"); ``` -------------------------------- ### Get Latest Visual Studio Installation with Specific Workload Source: https://github.com/cake-build/website/blob/master/input/blog/2017-03-27-vswhere-and-visual-studio-2017-support.md Use VSWhereLatest with VSWhereLatestSettings to specify a required workload, such as 'Microsoft.VisualStudio.Workload.ManagedDesktop', to find the latest installation that includes it. This ensures compatibility with specific development needs. ```csharp #tool nuget:?package=vswhere DirectoryPath vsLatest = VSWhereLatest(new VSWhereLatestSettings { Requires = "Microsoft.VisualStudio.Workload.ManagedDesktop"}); FilePath msBuildPathX64 = (vsLatest==null) ? null : vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/amd64/MSBuild.exe"); MSBuild("./src/Example.sln", new MSBuildSettings { ToolPath = msBuildPathX64 }); ``` -------------------------------- ### Get Latest Visual Studio Installation Path Source: https://github.com/cake-build/website/blob/master/input/blog/2017-03-27-vswhere-and-visual-studio-2017-support.md Use VSWhereLatest to find the path to the latest Visual Studio installation and then construct the MSBuild path. This is useful when you want to ensure you are using the most recent version. ```csharp #tool nuget:?package=vswhere DirectoryPath vsLatest = VSWhereLatest(); FilePath msBuildPathX64 = (vsLatest==null) ? null : vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/amd64/MSBuild.exe"); MSBuild("./src/Example.sln", new MSBuildSettings { ToolPath = msBuildPathX64 }); ``` -------------------------------- ### Install and Run EF Version using Command Alias (Frosting Host) Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/tools/running-tools.md Configure the Cake host in Frosting to install the `dotnet-ef` tool during startup, enabling its execution via the `Command` alias in tasks. ```csharp public sealed class Program : IFrostingStartup { public static int Main(string[] args) { return new CakeHost() .InstallTool(new Uri("dotnet:?package=dotnet-ef&version=8.0.0")) .Run(args); } } ``` -------------------------------- ### Configure Cake Frosting 0.38.x Startup Source: https://github.com/cake-build/website/blob/master/input/docs/getting-started/upgrade.md In Cake Frosting 0.38.x, the Program class implements IFrostingStartup to configure services like context, lifetime, and working directory. ```csharp public class Program : IFrostingStartup { public static int Main(string[] args) { // Create the host. var host = new CakeHostBuilder() .WithArguments(args) .UseStartup() .Build(); // Run the host. return host.Run(); } public void Configure(ICakeServices services) { services.UseContext(); services.UseLifetime(); services.UseWorkingDirectory(".."); } } ``` -------------------------------- ### Using TaskOf for Typed Data Contexts in Cake Source: https://github.com/cake-build/website/blob/master/input/blog/2022-11-08-cake-v3.0.0-released.md Demonstrates how to use TaskOf to simplify working with shared typed data contexts. Specify the type parameter once to get relevant task methods. Requires setup for the context. ```csharp public record BuildData(bool Initialized); Setup(ctx => new BuildData(true)); TaskOf("TaskOfT") .Description("Very typed task") .WithCriteria((context, data) => data.Initialized) .Does((context, data) => context.Information("Initialized: {0}.", data.Initialized)) .Does(async (context, data) => await /* async work*/) .DoesForEach( (data, context) => new [] { data.Initialized }, (data, item, context) => context.Information("Item: {0}, Initialized: {1}.", item, data.Initialized) ) .DoesForEach( new [] { true, false }, (data, item, context) => context.Information("Item: {0}, Initialized: {1}.", item, data.Initialized) ); RunTarget("TaskOfT"); ``` -------------------------------- ### Install Yeoman and Cake Generator Source: https://github.com/cake-build/website/blob/master/input/blog/2016-09-23-cake-for-yeoman.md Install Yeoman and the generator-cake globally using npm. Ensure Node.js and npm are installed. ```bash npm install -g yo npm install -g generator-cake ``` -------------------------------- ### Install Specific Tool Version Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/tool/nuget-provider.md Installs a specific version of a tool package. If the version is omitted, the latest available version will be installed. ```csharp #tool nuget:?package=Cake.Foo&version=1.2.3 ``` -------------------------------- ### Install GitVersion.Tool using .NET Tools provider Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sdk/tools.md Installs the GitVersion.Tool package using the 'dotnet:' provider. This is a common way to manage .NET global tools within a build script. ```csharp Setup(context => { InstallTool("dotnet:?package=GitVersion.Tool&version=6.3.0"); }); ``` -------------------------------- ### Install Specific Addin Version Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/addin.md Specify a particular version of the NuGet package to be installed. If omitted, the latest available version will be installed. ```csharp #addin nuget:?package=Cake.Foo&version=1.2.3 ``` -------------------------------- ### Multi-file structure: Main build file Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sdk/ioc-container.md The main build file (`build.cs`) sets up tasks and resolves services. It relies on other files for service registration and implementation. ```csharp #:sdk Cake.Sdk #:property IncludeAdditionalFiles=build/**/*.cs var target = Argument("target", "Default"); Task("Default") .Does(() => { var logger = ServiceProvider.GetRequiredService(); logger.LogInfo("Hello from IoC Container!"); }); RunTarget(target); ``` -------------------------------- ### Install Specific Version of .NET Tool Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/tool/dotnet-provider.md Installs a specific version of a .NET tool. If the version is omitted, the latest available version will be installed. ```csharp #tool dotnet:?package=Octopus.DotNet.Cli&version=4.41.0 ``` -------------------------------- ### Find All Visual Studio Installations Source: https://github.com/cake-build/website/blob/master/input/blog/2017-03-27-vswhere-and-visual-studio-2017-support.md Use VSWhereAll to retrieve a collection of all installed Visual Studio directories, regardless of whether they are complete installations. This is useful for scenarios where multiple versions or configurations might be present. ```csharp #tool nuget:?package=vswhere DirectoryPathCollection allInstalled = VSWhereAll(); foreach(var install in allInstalled) { // Find the installation you need } ``` -------------------------------- ### Install Cake Bootstrapper Generator Source: https://github.com/cake-build/website/blob/master/input/blog/2016-09-23-cake-for-yeoman.md Install the Cake bootstrapper generator individually using Yeoman. ```bash yo cake:bootstrapper ``` -------------------------------- ### Install Cake Config Generator Source: https://github.com/cake-build/website/blob/master/input/blog/2016-09-23-cake-for-yeoman.md Install the Cake config generator individually using Yeoman. ```bash yo cake:config ``` -------------------------------- ### Example Execution Output for Multiple Targets Source: https://github.com/cake-build/website/blob/master/input/blog/2022-11-08-cake-v3.0.0-released.md Illustrates the execution order and timing when multiple targets are specified using RunTargets. ```bash ======================================== A ======================================== ======================================== C ======================================== ======================================== B ======================================== Task Duration -------------------------------------------------- A 00:00:00.0028166 C 00:00:00.0006761 B 00:00:00.0006161 -------------------------------------------------- Total: 00:00:00.0041088 ``` -------------------------------- ### Install Cake via Homebrew Source: https://github.com/cake-build/website/blob/master/input/blog/2015-07-31-cake-on-homebrew.md Use these commands to update your Homebrew package list and install Cake. ```bash brew update brew install cake ``` -------------------------------- ### C# 9 Records for Build State Source: https://github.com/cake-build/website/blob/master/input/blog/2021-02-07-cake-v1.0.0-released.md Demonstrates using C# 9 records to define build state and configure build data, including environment variables and MSBuild settings. Setup is performed using the Setup delegate. ```csharp public record StorageAccount(string Name, string Container, string Key); public record BuildData(string Version, DotNetCoreMSBuildSettings MSBuildSettings, StorageAccount StorageAccount) { public bool ShouldPublish { get; } = !string.IsNullOrEmpty(StorageAccount.Name) && !string.IsNullOrEmpty(StorageAccount.Container) && !string.IsNullOrEmpty(StorageAccount.Key); } Setup(context =>{ var version = context.Argument("version", "1.0.0"); return new ( version, new DotNetCoreMSBuildSettings() .WithProperty("Version", version) .WithProperty("Configuration", context.Argument("configuration", "Release")), new ( context.EnvironmentVariable("PUBLISH_STORAGE_ACCOUNT"), context.EnvironmentVariable("PUBLISH_STORAGE_CONTAINER"), context.EnvironmentVariable("PUBLISH_STORAGE_KEY") ) ); }); Task("Build") .Does((context, data) => context.Information("Building {0}", data.Version)); RunTarget("Build"); ``` -------------------------------- ### Organizing Tasks by Feature with Entry Points Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sdk/multiple-entry-points.md Organize build tasks into logical modules using separate `Main_*` entry points for different features like testing and packaging. This promotes a cleaner and more maintainable build script structure. ```csharp public static partial class Program { private static void Main_Testing() { Task("UnitTest") .Does(() => Information("Running unit tests...")); Task("IntegrationTest") .IsDependentOn("UnitTest") .Does(() => Information("Running integration tests...")); } private static void Main_Packaging() { Task("Pack") .Does(() => Information("Packing artifacts...")); Task("Publish") .IsDependentOn("Pack") .Does(() => Information("Publishing artifacts...")); } } ``` -------------------------------- ### Excluded file example Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sdk/preprocessor-directives/additional-files.md An example of a file (build/ExceptThisFile.cs) that is excluded from compilation using the ExcludeAdditionalFiles directive. This file will not be compiled. ```csharp // This class will not be compiled. public class UnusedLogic { } ``` -------------------------------- ### Install and Run Bicep CLI using NuGet Source: https://github.com/cake-build/website/blob/master/input/blog/2026-03-01-cake-v6.1.0-released.md Installs the Bicep CLI from NuGet for the current OS and architecture, then executes it to display its version. Requires platform-specific NuGet package identifiers. ```csharp Task("Install-Bicep") .Does(() => { var osArch = (Context.Environment.Platform.Family, RuntimeInformation.OSArchitecture); Information($"Installing bicep tool for {osArch}"); FilePath[] bicepToolPaths; switch (osArch) { case (PlatformFamily.Windows, System.Runtime.InteropServices.Architecture.X64): bicepToolPaths = InstallTool("nuget:?package=Azure.Bicep.CommandLine.win-x64&version=0.41.2&include=/**/bicep.exe"); break; case (PlatformFamily.Windows, System.Runtime.InteropServices.Architecture.Arm64): bicepToolPaths = InstallTool("nuget:?package=Azure.Bicep.CommandLine.win-arm64&version=0.41.2&include=/**/bicep.exe"); break; case (PlatformFamily.Linux, System.Runtime.InteropServices.Architecture.X64): bicepToolPaths = InstallTool("nuget:?package=Azure.Bicep.CommandLine.linux-x64&version=0.41.2&include=/**/bicep"); break; case (PlatformFamily.Linux, System.Runtime.InteropServices.Architecture.Arm64): bicepToolPaths = InstallTool("nuget:?package=Azure.Bicep.CommandLine.linux-arm64=0.41.2&include=/**/bicep"); break; case (PlatformFamily.OSX, System.Runtime.InteropServices.Architecture.X64): bicepToolPaths = InstallTool("nuget:?package=Azure.Bicep.CommandLine.osx-x64&version=0.41.2&include=/**/bicep"); break; case (PlatformFamily.OSX, System.Runtime.InteropServices.Architecture.Arm64): bicepToolPaths = InstallTool("nuget:?package=Azure.Bicep.CommandLine.osx-arm64&version=0.41.2&include=/**/bicep"); break; default: Warning($"Platform {osArch.Family} with architecture {osArch.OSArchitecture} is not supported."); return; } var bicepTool = bicepToolPaths.FirstOrDefault() ?? throw new FileNotFoundException("Failed to resole tool"); Information($"Installed bicep to {bicepTool}"); Command( new CommandSettings { ToolExecutableNames = ["bicep", "bicep.exe"], ToolName = "bicep", ToolPath = bicepTool }, "--version"); }); ``` -------------------------------- ### Install Tool by Package Name Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/tool/nuget-provider.md Installs a tool package using only its name. The NuGet provider will default to nuget.org as the source. ```csharp #tool nuget:?package=Cake.Foo ``` -------------------------------- ### Global Setup and Teardown for Cake .NET Tool Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/setup-and-teardown.md Use Setup and Teardown to execute code before the first task and after the last task. These are only called if tasks are actually run. ```csharp Setup(context => { // Executed BEFORE the first task. }); Teardown(context => { // Executed AFTER the last task. }); ``` -------------------------------- ### OmniSharp Warning: Cake script service not connected Source: https://github.com/cake-build/website/blob/master/input/docs/integrations/editors/vscode/intellisense.md This warning indicates that Cake.Bakery is not installed. Ensure Cake.Bakery is installed to resolve this. ```log [warn]: OmniSharp.Cake.CakeProjectSystem Cake script service not connected. Aborting. ``` -------------------------------- ### Setting Configuration via Command Line Source: https://github.com/cake-build/website/blob/master/input/docs/running-builds/configuration/custom-configurations.md Provide configuration settings directly on the command line. Separate the section and key with an underscore, followed by the value. ```sh # provide the setting as option to the command line\n# by separating section and key with an underscore.\ndotnet cake build.cake --MySection_MyKey=MyValue ``` -------------------------------- ### Models file example Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sdk/preprocessor-directives/additional-files.md An example of a models file (build/Models.cs) for a multi-file Cake application. This file defines the BuildConfiguration class. ```csharp public class BuildConfiguration { public string ProjectName { get; set; } = ""; public string Version { get; set; } = ""; } ``` -------------------------------- ### Create and Run Cake Host with Cake Frosting 1.0 Source: https://github.com/cake-build/website/blob/master/input/docs/getting-started/upgrade.md Cake Frosting 1.0 simplifies host creation and execution using CakeHost directly. Configure context, lifetime, and working directory before running. ```csharp // Create and run the host. return new CakeHost() .UseContext() .Run(args); ``` -------------------------------- ### Create Minimal Cake File-Based Project Source: https://github.com/cake-build/website/blob/master/input/blog/2025-11-11-cake-v6.0.0-released.md Use the 'cakeminimalfile' template for the simplest possible Cake project setup. This is ideal for quick testing or minimal build requirements. ```bash dotnet new cakeminimalfile --name cake ``` -------------------------------- ### Include all C# files in a directory Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/sdk/preprocessor-directives/additional-files.md This example shows how to include all C# files within the 'build' directory and its subdirectories using a glob pattern. ```csharp #:property IncludeAdditionalFiles=build/**/*.cs ``` -------------------------------- ### Exclude Specific Files from NuGet Package Source: https://github.com/cake-build/website/blob/master/input/docs/writing-builds/preprocessor-directives/tool/nuget-provider.md Excludes specific files from being installed from a NuGet package. Use this to avoid installing unwanted assets. ```csharp #tool nuget:?package=Cake.Foo&exclude=/**/Foo.exe ```