This repository demonstrates minimal, modern usage of Cake.Sdk for .NET build automation. It showcases file-based, multi-file-based, and project-based approaches for defining Cake build scripts, and includes a minimal .NET class library.
- File-based build script: Standalone
cake.cs
using Cake Sdk directives. - Multi-file-based build script:
multifile-build/cake.cs
with additional files in build folder. - Advanced multi-file-based build script:
multifile-build-advanced/cake.cs
with organized structure, dependency injection, and service patterns. - Project-based build script:
build/build.csproj
referencing Cake.Sdk. - Pinned versions: .NET SDK and Cake.Sdk versions are pinned via
global.json
. - CI examples: Example GitHub Actions workflows for all approaches.
/
├── cake.cs # File-based Cake build script
|
├── build/
│ └── build.csproj # Project-based Cake build script using Cake.Sdk
|
├── multifile-build/
│ ├── cake.cs # Multi-file based Cake build script
│ └── build/
│ └── BuildData.cs # BuildData model for Multi-file build script
|
├── multifile-build-advanced/
│ ├── cake.cs # Advanced multi-file based Cake build script
│ └── build/
│ ├── Models/
│ │ └── BuildData.cs # BuildData model with Rebuild property
│ ├── Services/
│ │ ├── IMyService.cs # Service interface
│ │ └── MyService.cs # Service implementation with GitVersion logic
│ ├── IoC.cs # Dependency injection configuration
│ └── Task.cs # Additional task definitions
|
├── src/
│ └── Example/
│ └── Example.csproj # Minimal .NET class library (net10.0)
|
├── global.json # Pins .NET SDK and Cake.Sdk versions
├── .github/
│ └── workflows/
│ ├── CakeFile.yml # GitHub Actions: file-based build
│ ├── CakeProj.yml # GitHub Actions: project-based build
│ ├── Cake_Sdk-MultiFile.yml # GitHub Actions: multi-file-based build
│ └── Cake_Sdk-MultiFile-Advanced.yml # GitHub Actions: advanced multi-file-based build
|
└── README.md # This file
- File-based build:
Run with:dotnet cake cake.cs
- Project-based build:
Run with:
dotnet run --project build/build.csproj
- Multi-file-based build:
Run with:
dotnet cake multifile-build/cake.cs
- Advanced multi-file-based build:
Run with:
dotnet cake multifile-build-advanced/cake.cs
- .github/workflows/CakeFile.yml: Runs the file-based build script on push/PR.
- .github/workflows/CakeProj.yml: Runs the project-based build script on push/PR.
- .github/workflows/Cake_Sdk-MultiFile.yml: Runs the multi-file-based build script on push/PR.
- .github/workflows/Cake_Sdk-MultiFile-Advanced.yml: Runs the advanced multi-file-based build script on push/PR.
All workflows use the pinned .NET SDK and Cake.Sdk versions from global.json
.
Cake.Sdk is a custom SDK for Cake build automation, providing:
- Minimal project configuration
- Optimized build settings
- Built-in source generation (via Cake.Generator)
- Automatic inclusion of Cake.Core, Cake.Common, and Cake.Cli
Requirements: .NET 8.0 or later