Polyfun
Polyfun

Reputation: 9639

How to stop TFS Build when custom task fails

I am calling a custom task (derived from Microsoft.Build.Utilities.Task) from the AfterDropBuild target in my TFSBuild.proj. If my Execute override returns false, the build log shows the task as FAILED, but I still get a successful build, which means that I do not realise there is a problem with the build. How do I ensure that the build as a whole also fails?

Edit: This is TFS 2008.

Upvotes: 2

Views: 580

Answers (1)

Brian Kretzler
Brian Kretzler

Reputation: 9938

You've created a mismatch between logged errors and your task result. You need to first log an error, with Log.LogError. Then return !Log.HasLoggedErrors from your tasks, always. (from trick #2 in the book "MSBuild Trickery").

Upvotes: 4

Related Questions