![]() |
VOOZH | about |
<Sdk Name="Cake.Sdk" Version="6.2.0" />
#:sdk Cake.Sdk@6.2.0
A custom SDK that provides a convenient way to create Cake projects with minimal configuration. This SDK automatically sets up common properties and provides a streamlined development experience for Cake-based build automation projects.
.csproj fileCreate a new project file with minimal configuration:
<Project Sdk="Cake.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>
Here's a minimal example of a Cake SDK program
var target = Argument("target", "Default");
Task("Default")
.Does(() =>
{
Information("Hello from Cake!");
});
RunTarget(target);
dotnet run --project [path to csproj] -- [arguments]
i.e.
dotnet run --project build/build.csproj -- --target=Build
Here's a minimal example using the single file approach:
#:sdk Cake.Sdk
var target = Argument("target", "Default");
Task("Default")
.Does(() =>
{
Information("Hello from Cake!");
});
RunTarget(target);
To execute a single file-based app:
dotnet run [path to cs file] -- [arguments]
i.e.
dotnet run build.cs -- --target=Build
Note: File-based Cake apps require .NET 10 or later.
For larger file-based Cake apps, you can organize your code into multiple files. Use the IncludeAdditionalFiles and ExcludeAdditionalFiles properties to control which files are included during compilation. This allows you to place models, utility functions, and other code in separate files.
build.cs
#:sdk Cake.Sdk
#:property IncludeAdditionalFiles=build/**/*.cs
#:property ExcludeAdditionalFiles=build/**/Except*.cs
var target = Argument("target", "Default");
var config = new BuildConfiguration
{
ProjectName = "MyProject",
Version = "1.0.0"
};
Task("Default")
.Does(() =>
{
BuildUtilities.LogInfo($"Building {config.ProjectName} v{config.Version}");
});
RunTarget(target);
This will include all .cs files in the build directory...
build/Models.cs
public class BuildConfiguration
{
public string ProjectName { get; set; } = "";
public string Version { get; set; } = "";
}
build/Utilities.cs
public static partial class Program
{
public static void LogInfo(string message)
{
Information($"INFO: {message}");
}
}
...except for files that match the ExcludeAdditionalFiles pattern.
build/ExceptThisFile.cs
// This class will not be compiled.
public class UnusedLogic
{
}
The Cake.Generator package is included by default with Cake.Sdk, providing automatic source generation capabilities without any additional configuration needed.
Install tools using the provided methods:
// Install a single tool
InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.12.0");
// Install multiple tools
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"
);
Register and resolve services using the IoC container:
// Register services
static partial void RegisterServices(IServiceCollection services)
{
services.AddSingleton<IMyService, MyService>();
}
// Resolve services in tasks
Task("MyTask")
.Does(() => {
var service = ServiceProvider.GetRequiredService<IMyService>();
service.DoSomething();
});
You can define multiple entry points using Main_* prefixed methods that are automatically discovered and executed:
// Program.Main.cs
public static partial class Program
{
private static void Main_One()
{
Task(nameof(Main_One))
.IsDependeeOf("Clean")
.Does(() => Information("Hello from Main_One"));
}
private static void Main_Two()
{
Task(nameof(Main_Two))
.IsDependeeOf("Clean")
.Does(() => Information("Hello from Main_Two"));
}
}
The Cake.Sdk automatically configures the following properties:
OutputType: ExeNullable: enableImplicitUsings: enableOptimize: falseDebugType: portableDebugSymbols: trueLangVersion: latestPublishAot: falseJsonSerializerIsReflectionEnabledByDefault: trueThe following packages are automatically included when using Cake.Sdk:
Learn more about Target Frameworks and .NET Standard.
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.2.0 | 22,682 | 5/22/2026 |
| 6.1.1 | 64,248 | 3/2/2026 |
| 6.1.0 | 4,254 | 3/1/2026 |
| 6.0.0 | 67,469 | 11/11/2025 |
| 5.1.25296.94-beta | 597 | 10/23/2025 |
| 5.1.25292.90-beta | 409 | 10/19/2025 |
| 5.1.25277.88-beta | 549 | 10/4/2025 |
| 5.0.25276.86-beta | 350 | 10/3/2025 |
| 5.0.25257.82-beta | 545 | 9/14/2025 |
| 5.0.25253.70-beta | 444 | 9/10/2025 |
| 5.0.25225.53-beta | 544 | 8/13/2025 |
| 5.0.25225.51-beta | 434 | 8/13/2025 |
| 5.0.25198.49-beta | 589 | 7/17/2025 |