Building multipe .NET Solutions with a batch file

If you have multiple solutions with projects (who’m depend on each other) you can create a .bat file to (re)build all projects instead of opening all solutions and (re)building them manually.

Open notepad and add following text

ECHO ====================
ECHO Multiple Solution Rebuilder
ECHO ====================

REM Clearing all logs if the folder exist
IF EXIST "buildlogs" (
cd "buildlogs"
del *.log /F /Q
    if EXIST "warnings" (
        cd "warnings"
        del *.log /F /Q
REM ECHO Building Solution 1
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin\MSBuild.exe" YourPathToYourSolution\Solution1.sln /p:Configuration=Debug /p:Platform="Any CPU" -v:quiet -flp1:logfile=./buildlogs/Solution1.log;errorsonly -flp2:logfile=./buildlogs/warnings/Solution1.log;warningsonly
REM ECHO Building Solution 2
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin\MSBuild.exe" YourPathToYourSolution\Solution2.sln /p:Configuration=Debug /p:Platform="Any CPU" -v:quiet -flp1:logfile=./buildlogs/Solution2.log;errorsonly -flp2:logfile=./buildlogs/warnings/Solution2.log;warningsonly

ECHO All done!
ECHO You can find errors in the buildlogs folder
ECHO You can find warnings in the buildlogs\warnings folder


Just replace YourPathToYourSolution\Solution1.sln, save the file with a .bat extension and you’re good to go.

Leave a Reply