Reputation: 4929
I am trying to build multiple .sln files inside a batch file. Everything works great so far. I am trying to add a check inside the batch file, so if number of errors is greater than 0 then the batch file stops executing and doesn't build the next .sln files. How can I do that? Basically something like:
msbuild test.sln (check if build error > 0 stop) msbuild test2.sln
Upvotes: 1
Views: 1762
Reputation: 9708
In my opinion it's much easier to use a custom msbuild file here and use the msbuild task with your set of solutions. See here for the details.
Upvotes: 1
Reputation: 26599
MSBUILD will set the ERRORLEVEL, so something along the lines of:
msbuild test.sln
IF NOT ERRORLEVEL 0 exit 1
Edit: Apparently it should be:
msbuild test.sln
IF ERRORLEVEL 1 exit 1
Upvotes: 4
Reputation: 773
msbuild.exe test.sln
if errorlevel 1 goto :errors
msbuild.exe test2.sln
if errorlevel 1 goto :errors
:: ...
:: Everything was fine.
echo Build completed without errors.
goto :eof
:error
echo Build failed.
Upvotes: 1