Search code examples
buildtfsmsbuildreleasedevenv

specify project file of a solution using msbuild


I want the commandline for building a particular project of a solution using msbuild like we do with devenv.com.In devenv.com we can specify a project of a solution using following commandline

devenv.com /Build Release|x86 test.sln /project "testproject"

Using the above commandline i can build the testproject in the test.sln using devenv.com.What is the commandline for msbuild for the same solution.

Thanks


Solution

  • 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