Search code examples
cakebuild

Referencing addins from secondary script file


I have a cake file with my Tasks defined. I also have a second cake file with some classes defined. In the second file, I would like to reference e.g. Cake.Json, and maybe Cake.Svn. But I cannot figure out how reference them.

How would I do that?


Solution

  • Both addins and utility Cake scripts are references using pre-processor directives.

    Addin directive

    Usage

    #addin nuget:?package={NuGet Package Id}&version={NuGet package version}
    

    Example:

    #addin nuget:?package=Cake.Json&version=3.0.1
    

    Reference directive

    Usage

    #r "Path to assembly / dll"
    

    Example:

    #r "bin/Cake.Json.dll"
    

    Load directive

    Usage

    #load "Path to cake file"
    

    Example:

    #load "scripts/common.cake"
    

    Reference

    Read more about pre-processor directives at

    https://cakebuild.net/docs/fundamentals/preprocessor-directives