Custom post build check with error message

2019-07-23 06:47发布

问题:

I want to launch my specific code from post build event and see any error messages as build errors. To do this I created another console application in a solution and added it to Build-Postbuild list in the main project settings.

The problem is that Visual Studio Error List displays only error code but no output at all.

回答1:

I'm not 100% sure what you are asking, but if you want to get output of custom tools to behave like output in VS, it must be in a format like:

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

So for example if your post-build event outputs

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

then this will be recognized as an error and the Error List will contain an entry which behaves just like your typical compiler error, so you can even doubleclick to go to myfile.c line 123. But even something simple as

error: my program failed

will also be shown in the Error List.