CallTarget Task

Note

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

Invokes the specified targets within the project file.

Task Parameters

The following table describes the parameters of the CallTarget task.

Parameter Description
RunEachTargetSeparately Optional Boolean output parameter.

If true, the MSBuild engine is called once per target. If false, the MSBuild engine is called once to build all targets. The default value is false.
TargetOutputs Optional ITaskItem[] output parameter.

Contains the outputs of all built targets.
Targets Optional String[] parameter.

Specifies the target or targets to build.
UseResultsCache Optional Boolean parameter.

If true, the cached result is returned if present.

Note When an MSBuild task is run, its output is cached in a scope (ProjectFileName, GlobalProperties)[TargetNames] as a list of build items.

Remarks

If a target specified in Targets fails and RunEachTargetSeparately is true, the task continues to build the remaining targets.

If you want to build the default targets, use the MSBuild Task and set the Projects parameter equal to $(MSBuildProjectFile).

In addition to the parameters listed above, this task inherits parameters from the TaskExtension class, which itself inherits from the Task class. For a list of these additional parameters and their descriptions, see TaskExtension Base Class.

Example

The following example calls TargetA from inside CallOtherTargets.

<Project DefaultTargets="CallOtherTargets"  
    xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
  
    <Target Name="CallOtherTargets">  
        <CallTarget Targets="TargetA"/>  
    </Target>  
  
    <Target Name="TargetA">  
        <Message Text="Building TargetA..." />  
    </Target>  
  
</Project>  

See Also

Task Reference
Targets