如何将 MSBuild 中的目标绑定到一般错误
我们使用 TFS 构建,并且在配置中有几个自定义步骤(例如,在 AfterCompile 目标中运行 NUnit 测试、在 AfterDropBuild 目标中运行部署步骤等)。现在我想添加在损坏的版本上发送电子邮件的功能。我已从 MS 社区任务配置了一个邮件任务并将其放入 BeforeOnBuildBreak
目标。如果出现编译错误,这非常有效,我们甚至会收到通知电子邮件。
但是,当某些自定义任务出现错误时(例如,此 NUnit 测试运行中有一个失败的测试),BeforeOnBuildBreak 目标甚至不会执行。是否有其他(更通用的)目标或任何其他方式来执行自定义逻辑,以防构建失败?
We are using TFS build and we have a couple of custom steps within the configuration (e.g. running NUnit tests in AfterCompile
target, deployment steps in AfterDropBuild
target etc.). Now I wanted to add the functionality of sending emails on broken builds. I have configured a mail task from MS Community tasks and put it to the BeforeOnBuildBreak
target. This works perfectly if there is a compilation error, we are even getting the notification emails.
However, when there is an error in some custom task (e.g. there is a failed test in this NUnit test run), the BeforeOnBuildBreak target is not even executed. Is there some other (more general) target or any other way to execute custom logic in case of any build failure ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于单个任务,您可以设置
ContinueOnError="True"
属性,然后检查错误、发送通知并使用Error
任务手动失败构建。For individual tasks you could set
ContinueOnError="True"
property and then check for errors, send notification and fail the build manually using theError
task.