Is there way a to automatically run a Visual Studio event on build failure?

Viewed 92

In the Visual Studio Project Properties you have options to specify Pre-Build, Pre-Link, Custom Build, and Post-Build events. This is how they fit in the build process according to Microsoft:

Pre-Build event
Custom build tools on individual files
MIDL
Resource compiler
The C/C++ compiler
Pre-Link event
Linker or Librarian (as appropriate)
Manifest Tool
BSCMake
Custom build step on the project
Post-Build event

Thus if the build fails at the C/C++ Compilation stage, this means Pre-Link, Custom, and Post-Build steps won't run. I haven't tried Custom but I can confirm in VS2019 that Pre-Link and Post-Build events don't happen if there are compilation errors.

Just like with the other customizable events, I would like to be able to run an arbitrary command after a build error (e.g. touch a file with "Compilation failed!", but could be anything).

Let's say in my C project that I have a syntax error, I click Build->Build Solution, compilation fails, and in the Output Window I see "Done building project -- FAILED". Is there a way to have had Visual Studio automatically run an event after this Build failure?

0 Answers
Related