为什么在VS2012中在Post-Build事件中输出'error:'会破坏我的构建?

4
添加
cmd.exe /c "ECHO error : unexplainable"

导致这个问题的原因是:

1>------ Build started: Project: xxx, Configuration: Debug Win32 ------
1>EXEC : error : unexplainable
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5): error MSB3073: The command "cmd.exe /c "ECHO error : unexplainable"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(134,5): error MSB3073: :VCEnd" exited with code -1.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

只有当字符串中紧跟着一个':'字符时才会出现'error'。

cmd.exe /c ECHO "错误:可解释的" - Hans Passant
@HansPassant 哇哈哈,太好笑了。 - coda
1个回答

4
这是MSBuild中的一个漏洞: https://github.com/Microsoft/msbuild/issues/766 “PostBuildEvent”目标使用的“Exec”任务默认情况下应该将“IgnoreStandardErrorWarningFormat”设置为true,但它没有。因此,当在输出中找到“error:”时,会导致失败。
覆盖项目中预定义的“PostBuildEvent”,就像这里一样:Can I include a .targets file in a .props property sheet? 修复此问题的不可靠方法是通过修改位于C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(第134行)的“PostBuildEvent”目标,将IgnoreStandardErrorWarningFormat="true"添加到“Exec”任务中。请注意,这可能不是一个可靠的解决方法。请按照上述建议进行操作。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接