MSBuild TaskĀ 

Builds MSBuild projects from another MSBuild project.


The following table describes the parameters of the MSBuild task.

Parameter Description


Required ITaskItem[] parameter.

Specifies the project files to build.


Optional String parameter.

A semicolon-delimited list of property name/value pairs to apply as global properties to the child project. Specifying this parameter is functionally equivalent to setting properties with the /property switch when building with MSBuild.exe. For example:



Optional Boolean parameter.

If true, the relative paths of target output items from the built projects have their paths adjusted to be relative to the calling project. Default is false.


Optional Boolean parameter.

If true, the task runs each target with a separate invocation. This means that subsequent targets will be built even if previously invoked targets failed. Default is false.


Optional Boolean parameter.

If true, forces the task to stop building the remaining projects as soon as any of them fail.


Optional ITaskItem[] read-only output parameter.

Returns the outputs of the built targets from all the project files. Only the outputs from the targets that were specified are returned, not any outputs that may exist on targets that those targets depend on.

The TargetOutputs parameter also contains the following metadata:

  • MSBuildProjectFile: The MSBuild project file that contains the target that set the outputs.

  • MSBuildTargetName: The target that set the outputs.


If you want to identify the outputs from each project file or target separately, run the MSBuild task separately for each project file or target. If you run the MSBuild task only once to build all the project files, the outputs of all the targets are collected into one array.


Optional String parameter.

Specifies the target or targets to build in the project files. Use a semicolon to separate a list of target names. If no targets are specified in the MSBuild task, the default targets specified in the project files are built.


The targets must exist in all the project files. If they do not, a build error occurs.


Unlike using the Exec Task to invoke MSBuild.exe, this task uses the same MSBuild process to build the child projects. The list of already-built targets that can be skipped is shared between the parent and child builds. This task is also faster because no new MSBuild process is created.

This task can process not only project files but also Visual Studio 2005 solution files.


The following example uses the MSBuild task to build the projects specified by the ProjectReferences item collection. The resulting target outputs are stored in the AssembliesBuiltByChildProjects item collection.

<Project xmlns="">

        <ProjectReferences Include="*.*proj" />

    <Target Name="BuildOtherProjects">
                ItemName="AssembliesBuiltByChildProjects" />


See Also


MSBuild Tasks

Other Resources

MSBuild Task Reference