My solution has two projects: c++ dll and c# web. Dll project has pre-built event like this
IF 2 == 1
(
echo ERROR: Dll building error
)
And, obviously, this condition not interrupts building process and it finishes with success, if I run it for dll project.
But.. the Web project depends on the dll and therefore uilds it, in turn, by MSBUILD.exe command in it own pre-build event. That is, as a result, pre-build parent (MSBUILD for web) following by nested pre-build childs (IF for dll). . And if I try to build web project, it interrupts with message Dll building error (from the dll project pre-built event) after child dll project by MSBUILD.exe (in web pre-built event) has built with success!!! - result dll file has appeared in output dir!.
What it's means? Child pre-build event conditions incorrectly interrupts parent build process?
The problem appears to be that you're misusing MSBuild. The proper way to handle "subprojects" is to use a Solution. In this solution, you have both projects, and a project dependency from the web project on the DLL. You build the solution, and that's one MSBuild command. Therefore, the C# web project does not need to start another MSBuild command.
MSBuild, when using a solution file, sees the real dependencies and handles build failures correctly. Note that a "echo ERROR" in a pre-build event is just text on a screen, not a build failure. You'll need to exit /b 1
the pre-build step to stop the build