出现编译错误时立即停止 MSBuild 处理
我编写了一个批处理文件,执行时会构建一个 Visual Studio 解决方案。该解决方案由几个 C# 项目组成。我正在为此使用 MSBuild 实用程序。当任何项目中存在编译错误时,如何阻止构建进一步进行? 此外,我如何获取错误消息并将其显示在命令提示符上?
I have written a batch file, which when executed builds a visual studio solution. The solution comprises of few C# projects. I am using MSBuild utility for this. How can i stop the build from proceeding further when there are compilation errors in any of the projects?
Further how can i get the error messages and display them on command prompt?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
构建 Visual Studio 解决方案时,不支持首次失败时停止。
您可以通过执行以下步骤解决此问题:
set msbuildemitsolution=1
);RunEachTargetSeparately="true"
更改为RunEachTargetSeparately="false"
;此答案基于 Dan Moseley 对帖子的回答在 MSDN 论坛上。
There's no support for stop on first failure when building a visual studio solution.
You can workaround this by taking the following steps:
set msbuildemitsolution=1
);RunEachTargetSeparately="true"
in the target named Build toRunEachTargetSeparately="false"
;This answer is based on Dan Moseley answer to a post on MSDN Forums.
如果您发布了批处理文件的相关部分,那么给您答案会更容易。尽管如此,对于问题的第二部分,这里有一个示例,我如何在我们的构建脚本之一中解决几乎相同的问题:
It would be easier to give you an answer if you would have posted relevant parts of your batch file. Nevertheless, for your second part of the question, here is an example how I solved almost the same issue in one of our build scripts: