Cake supports different ways to share build code across multiple projects and repositories.
|Method||Sharing of classes||Sharing of aliases||Sharing of tasks|
|Recipe NuGet packages|
|Assemblies in NuGet packages|
Recipe NuGet packages
Cake build scripts can be published as NuGet packages, so called Recipes. These packages can contain shared tasks and can be consumed by other build scripts.
Writing Recipe NuGet packages
To create a Recipe NuGet package add the
.cake files to the
Content folder in the NuGet package.
Consuming Recipe NuGet packages
Make sure to pick a Recipe NuGet package compatible with your runner.
Cake .NET Tool
When using Cake .NET Tool, the load directive can be used with the
to download the Recipe NuGet packages and load all
.cake files in the
The following example loads version 1.0.0 of the
MyRecipePackage NuGet package:
When using Cake Frosting, Recipe NuGet package can be referenced like any other NuGet package:
<PackageReference Include="MyRecipePackage" Version="1.0.0" />
See Creating addins for instructions how to create your custom addin.
Addins can be loaded using the addin directive.
Assemblies in NuGet packages
Classes can be shared in .NET assemblies deployed in NuGet packages.
Consuming assemblies from NuGet packages
NuGet packages can be loaded using the addin directive.