I have written a batch file, which when executed builds a visual studio solution. The solution comprises of few C# projects. I am using MSBuild utility for this. How can i stop the build from proceeding further when there are compilation errors in any of the projects? Further how can i get the error messages and display them on command prompt?
There's no support for stop on first failure when building a visual studio solution.
You can workaround this by taking the following steps:
set msbuildemitsolution=1
);RunEachTargetSeparately="true"
in the target named Build to RunEachTargetSeparately="false"
;This answer is based on Dan Moseley answer to a post on MSDN Forums.
It would be easier to give you an answer if you would have posted relevant parts of your batch file. Nevertheless, for your second part of the question, here is an example how I solved almost the same issue 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%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With