Cake.exe in every project folder

If you like your Cake, and eat it to, you probably have a lot of Cake build artifacts hanging around. I have artifacts in each project that uses Cake. I always thought "Meh, storage is cheap", so I never worried about cleaning up my crumbs. When I read that Cake v0.22.0 resolved Github Issue 753 I reconsidered my stance. I decided having a global cache of versioned dependencies was better than scattered versioned dependencies. Secretly I am hoping a global cache may get me one step closer to local offline build.

One Cake to rule them all

Cake has several configuration options for setting up a global folder.

  • Environment variables
  • .ini file
  • Command line argument

Command line doesn't feel scalable and .ini files worry me. I consume a lot of Cake and I want each of my projects to source their dependencies from one folder. I don't want to make configuration changes per project, some of which I don't own. I've decided to go with environment variables because they are consistent across platform and accessible from the command line. I used the following scripts to setup my global Cake environment variables.


Bash Profile

Modify the bootstrap script

If you're like me, you probably just downloaded the stock bootstrapper from Cake. Why not? Unless you have more pressing needs the stock bootstrapper will get you going. With this change to centralize my Cake, I want my bootstrapper to either take in my tool path as a parameter, or set the path in the script and make it aware of my global configuration.

$ToolPath = [Environment]::GetEnvironmentVariable("CAKE_TOOLS_PATH", "User")

if($ToolPath -eq $null)
    $ToolPath = Join-Path $PSScriptRoot "tools"

if[ -z "$TOOLS_DIR"]; then

These steps are all it takes to configure a machine to use global Cake configuration. You can rinse and repeat the last step for the other Environment Variables defined in your Cake script. I hope this setup makes cleaning up your cake crumbs quick and easy.

comments powered by Disqus