How to make msbuild fail when a target fails in a VS solution?
I'm using msbuild on the command line to build a VS2012 solution containing a C++ project. The project has a target that runs after the build: <Target Name="RunTargetAfterBuild" AfterTargets="Build"> <Error Text="I am a failing target" /> </Target> I want msbuild to return an error when building, however somewhere in the process of building, the error gets lost and msbuild reports 'Build succeeded'. Consequently the ERRORLEVEL is still set to 0 so it's pretty hard to detect if something went wrong during automated builds. How do I make msbuild propagate this error all the way to the top level