How to: Build Specific Targets in Solutions By Using MSBuild.exe

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use MSBuild.exe to build specific targets of specific projects in a solution.

To build a specific target of a specific project in a solution

  1. At the command line, type MSBuild.exe <SolutionName>.sln, where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.

  2. Specify the target after the /t switch in the format ProjectName:TargetName.

Example

The following example executes the Rebuild target of the NotInSlnFolder project, and then executes the Clean target of the InSolutionFolder project, which is located in the NewFolder solution folder.

msbuild SlnFolders.sln /t:NotInSlnfolder:Rebuild;NewFolder\InSolutionFolder:Clean  

See Also

Command-Line Reference
MSBuild Reference
MSBuild
MSBuild Concepts