Using the Error()
method only logs an error. But what if I want to abort the build? I can throw an exception to abort the build but it does not seem right. So is there a proper way to abort?
var releaseNotes = ParseReleaseNotes("./ReleaseNotes.md");
if(releaseNotes.Version.ToString() != nugetVersion)
{
Error("Release notes are missing an entry for v{0}. Latest release notes are for v{1}", nugetVersion, releaseNotes.Version);
throw new Exception();
}
The Error
method is just a convenience method for logging an error. I understand the confusion though.
If something is wrong with that you cannot recover from, you should throw an exception to indicate it. The Cake script runner will then log the error (using the Error
method) and return exit code 1 to indicate that something went wrong.