specify project file of a solution using msbuild

msbuild test.sln /t:project /p:Configuration="Release" /p:Platform="x86" /p:BuildProjectReferences=false

Notice that what is assigned to /t is the project name in the solution, it can be different from the project file name.

Also, as stated in How to: Build specific targets in solutions by using MSBuild.exe:

If the project name contains any of the characters %, $, @, ;, ., (, ), or ', replace them with an _ in the specified target name.

You can also build multiple projects at once:

msbuild test.sln /t:project;project2 /p:Configuration="Release" /p:Platform="x86" /p:BuildProjectReferences=false

To rebuild or clean, change /t:project to /t:project:clean or /t:project:rebuild

Leave a Comment