Why outputting 'error: ' in Post-Build Event breaks my build in VS2012?

Why outputting 'error: ' in Post-Build Event breaks my build in VS2012?

添加

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' 字符串后跟 ':' 字符时才会发生。

这是 MSBuild 中的错误:https://github.com/Microsoft/msbuild/issues/766

'PostBuildEvent' 目标使用的 'Exec' 任务应该默认将 'IgnoreStandardErrorWarningFormat' 设置为 true 但它没有,因此在查找 'error:' 时失败在输出中。

解决这个问题的不可靠方法是修改 'PostBuildEvent' 中的目标 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(第 134 行)通过将 IgnoreStandardErrorWarningFormat="true" 添加到 'Exec' 任务

覆盖项目中的预定义 'PostBuildEvent',如下所示:Can I include a .targets file in a .props property sheet?