Search code examples
c#cakebuild

Cake Build - How to Invoke other Cake Build Scripts from another Cake Build Script


If I have a large code-base with many inter-dependent projects, for example, projects/A, projects/B, and projects/C, where A requires B, and B requires C, and each of these projects has a Cake build script, for example, projects/A/build.cake, projects/B/build.cake, and projects/C/build.cake, what is the best way to write the projects/A/build.cake such that it invokes the Cake build projects/B/build.cake as a dependency task.


Solution

  • My suggestion would be to keep each projects build.cake file isolated, only working/building that project. Then, I would have another, higher level build script which then used to run:

    https://cakebuild.net/api/Cake.Common.Tools.Cake/CakeAliases/5FCD85B6

    To invoke the project build scripts in the order that they are required.

    You could have something like:

    CakeExecuteScript("./projects/C/build.cake");
    CakeExecuteScript("./projects/B/build.cake");    
    CakeExecuteScript("./projects/A/build.cake");
    

    Obviously, you could wrap each of those in a try/catch to take action to stop the overall build, if one of the project builds fail.