user62958
user62958

Reputation: 4929

Visual Studio, MS Build

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

Answers (3)

Bas Bossink
Bas Bossink

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

Steven Robbins
Steven Robbins

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

Srdjan Jovcic
Srdjan Jovcic

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

Related Questions