Stop MSBuild processing immediately when compilation errors

I wrote a batch file that, when executed, creates a visual studio solution. The solution consists of several C # projects. For this I use the MSBuild utility. How can I stop the build if I continue to compile in any of the projects? How can I get error messages and display them on the command line?

+8
batch-file command-prompt msbuild
source share
2 answers

There is no support to stop at the first crash when creating a visual studio solution.

You can get around this by following these steps:

  • Set the msbuildemitsolution environment variable to 1 ( set msbuildemitsolution=1 );
  • Call MSBuild to generate the * .proj file from the VS target solution;
  • In the generated * .sln.proj file, change RunEachTargetSeparately="true" in an object named Build to RunEachTargetSeparately="false" ;
  • Call MSBuild to create an updated * .sln.proj file.

This answer is based on Dan Mosley responding to a post on MSDN forums .

+5
source share

It would be easier to give you an answer if you placed the relevant parts of your batch file. However, for your second part of the question, here is an example of how I solved almost the same problem in one of our build scripts:

 msbuild.exe /m /p:Configuration=Release /v:n theSolutionFile.sln >Build.log if ERRORLEVEL 1 goto :showerror find "0 Warn" Build.log >nul: if ERRORLEVEL 1 goto :showerror goto :EOF :showerror echo Build error occurred exit %ERRORLEVEL% 
+4
source share

All Articles