Search code examples
cakebuild

Relocate Cakes's tools directory


Some of our projects have their own tools directory, so adding tools to .gitignore is not an option

In build.ps1, I have tried modifying this:

$TOOLS_DIR = Join-Path $PSScriptRoot "tools"

to this:

$TOOLS_DIR = Join-Path $PSScriptRoot "caketools"

But tools fetched by Nuget eg. NUnit.ConsoleRunner, still implicitly extracts to tools.

I also tried to let Cake live alongside my projects tools by adding more specific excludes to .gitignore, like:

# Cake
tools/Cake
tools/NUnit.ConsoleRunner*
tools/nuget.exe
tools/packages*

But the problem is that Cake "owns" the tools folder, and thus wipes the directories already in my project's tools folder.


Solution

  • Have a look at the documentation here:

    https://cakebuild.net/docs/fundamentals/configuration

    It is possible to pass a configuration value(s) to Cake, either through an environment variable, command line argument, or configuration file, to instruct Cake on which folder to use for the tools, addins and modules folder.

    All available configuration options are detailed on this page:

    https://cakebuild.net/docs/fundamentals/default-configuration-values

    The default configuration values are:

    ; This is the default configuration file for Cake.
    ; This file was downloaded from https://github.com/cake-build/resources
    
    [Nuget]
    Source=https://api.nuget.org/v3/index.json
    UseInProcessClient=true
    LoadDependencies=false
    
    [Paths]
    Tools=./tools
    Addins=./tools/Addins
    Modules=./tools/Modules
    
    [Settings]
    SkipVerification=false
    

    when held within a cake.config file, and you can place this in the root of your repository, and Cake.exe will respect this location. If you are using a bootstrapper, you will still need to modify it to use the same location, as it doesn't know anything about the cake.config file.