I'm using the DoesForEach alias to run a task for a collection.
I want to report/act on success.
I cannot do this because it would run after every item in the collection:
Task("A")
.DoesForEach(GetFiles("**/*.txt"), (file) => {
//...
DoSomething(); // <---
});
I cannot do this because it would run for failures too:
Task("A")
.DoesForEach(GetFiles("**/*.txt"), (file) => {
//...
})
.Finally(() => {
DoSomething(); // <---
});
How can I do this?
(A workaround is to run a dependent task after this one - i.e. B->A - but that is a messy way to do it... unless it's the only way?)
Additionally to what devlead said, you could also add multiple actions to a task, like this:
And then there is also the finally block: