带有错误消息的自定义 post 构建检查

Custom post build check with error message

我想从 post 构建事件中启动我的特定代码,并将任何错误消息视为构建错误。为此,我在解决方案中创建了另一个控制台应用程序,并将其添加到主项目设置中的 Build-Postbuild 列表中。

问题是 Visual Studio 错误列表只显示错误代码而根本没有输出。

我不是 100% 确定你在问什么,但如果你想让自定义工具的输出表现得像 VS 中的输出,它必须采用如下格式:

<filename>(<line>): error <code>: <message>

例如,如果您的 post-build 事件输出

myfile.c(123): error CustomErrorCode: my program failed

然后这将被识别为错误,错误列表将包含一个条目,其行为与您的典型编译器错误一样,因此您甚至可以双击转到 myfile.c 第 123 行。 但即使是像

这样简单的东西
error: my program failed

也将显示在错误列表中。