Skip to content

Latest commit

 

History

History
67 lines (50 loc) · 2.74 KB

calltarget-task.md

File metadata and controls

67 lines (50 loc) · 2.74 KB
title ms.date ms.topic dev_langs helpviewer_keywords ms.assetid author ms.author manager ms.workload
CallTarget Task | Microsoft Docs
11/04/2016
reference
VB
CSharp
C++
jsharp
CallTarget task [MSBuild]
MSBuild, CallTarget task
bb1fe2c4-4383-436f-8326-c24cc4a46150
ghogen
ghogen
jillfra
multiple

CallTarget task

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 input 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 xref:Microsoft.Build.Framework.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).

When using CallTarget, MSBuild evaluates the called target in a new scope, as opposed to the same scope it's called from. This means that any item and property changes in the called target are not visible to the calling target. To pass information to the calling target, use the TargetOutputs output parameter.

In addition to the parameters listed above, this task inherits parameters from the xref:Microsoft.Build.Tasks.TaskExtension class, which itself inherits from the xref:Microsoft.Build.Utilities.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