The philosophy behind Cake is to reduce the number of dependencies for Cake as well as to not store executable in the source code repository. Instead a set of conventions are used to locate executables on disc.
- Use explicitly set tool path on ToolSettings ToolPath property.
- Via IToolLocator registered path (see example below).
- Try to find the tool by searching
./tools/**/mytool.exe
. - Look through all paths in the
PATH
environment variable and look formytool.exe
. - Ask the tool wrapper for additional, alternative paths.
By inheriting from the Tool
You can override and register tool paths using the IToolLocator Tools property on the ICakeContext:
Setup(context => {
context.Tools.RegisterFile("C:/ProgramData/chocolatey/bin/NuGet.exe");
});
If you want to use the tool resolution from your Cake script for generic tasks, i.e. starting a process, that's certainly possible using the Resolve(string) method:
Task("NuGet-Help-Install")
.Does(()=> {
FilePath nugetPath = Context.Tools.Resolve("nuget.exe");
StartProcess(nugetPath, new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("help")
.Append("install")
});
});