I use CAKE 0.22.0.
Whenever I set Target to RunTests, I want the task CleanUpTempFiles to execute once all unit tests are finished. According to the CAKE documentation, I can simply write the following:
Task("CleanUpTempFiles")
.IsDependentOn("RunTests")
.Does(() => { etc. });
However, this won't work for me, because sometimes I would like to run CleanUpTempFiles without actually running any tests. For example, I would like to add a task called RunJetBrainsDotCover, which is dependent on CleanUpTempFiles but not dependent on RunTests.
I thought of creating a method called CleanUpTempFiles, which I will then invoke as the final step within the Does clause of RunTests, and also as the first step within RunJetBrainsDotCover. However, I am not entirely satisfied with this approach -- I much prefer having CleanUpTempFiles as a task, because then it becomes more explicit what steps are involved in running each target.
Any advice?