Summary
- Assembly
- NAnt
.Core .dll - Namespace
- NAnt
.Core .Tasks - Interfaces
- Base Types
Syntax
[TaskName("call")]
public class CallTask : Task, IConditional
Examples
Call the target "build".
<call target="build" />
This shows how a project could 'compile' a debug and release build using a common compile target.
<project default="build">
<property name="debug" value="false" />
<target name="init">
<echo message="initializing" />
</target>
<target name="compile" depends="init">
<echo message="compiling with debug = ${debug}" />
</target>
<target name="build">
<property name="debug" value="false" />
<call target="compile" />
<property name="debug" value="true" />
<call target="compile" />
</target>
</project>
The NAnt.Core.Tasks.CallTask.CascadeDependencies parameter of the
NAnt.Core.Tasks.CallTask defaults to true,
causing the "init" target to be executed for both
the "debug" and "release" build.
This results in the following build log:
build:
init:
[echo] initializing
compile:
[echo] compiling with debug = false
init:
[echo] initializing
compile:
[echo] compiling with debug = true
BUILD SUCCEEDED
If the "init" should only be executed once, set the
NAnt.Core.Tasks.CallTask.CascadeDependencies attribute of the NAnt.Core.Tasks.CallTask
to false.
The build log would then look like this:
build:
init:
[echo] initializing
compile:
[echo] compiling with debug = false
compile:
[echo] compiling with debug = true
BUILD SUCCEEDED
Remarks
When the NAnt.Core.Tasks.CallTask is used to execute a target, both that
target and all its dependent targets will be re-executed.
To avoid dependent targets from being executed more than once, two options are available:
-
Add an "unless" attribute with value "${target::has-executed('
<target name>')}" to the dependent targets. -
Set the
NAnt.Core.Tasks.CallTask.CascadeDependenciesattribute on theNAnt.Core.Tasks.CallTasktofalse(recommended).
Attributes
| Type | Description |
|---|---|
| TaskNameAttribute | Indicates that class should be treated as a task. |
Properties
| Name | Value | Summary |
|---|---|---|
| CascadeDependencies | bool |
Execute the specified targets dependencies -- even if they have been
previously executed. The default is
true.
|
| CustomXmlProcessing | bool |
Gets a value indicating whether the element is performing additional
processing using the
NAnt.Core.Element.XmlNode that was used to
initialize the element.
Inherited from Element
|
| FailOnError | bool |
Determines if task failure stops the build, or is just reported.
The default is
true.
Inherited from Task
|
| ForceExecute | bool |
Force an execute even if the target has already been executed. The
default is
false.
|
| IfDefined | bool |
If
true then the task will be executed; otherwise,
skipped. The default is true.
Inherited from Task
|
| Location | Location |
Gets or sets the location in the build file where the element is
defined.
Inherited from Element
|
| LogPrefix | string |
The prefix used when sending messages to the log.
Inherited from Task
|
| Name | string |
The name of the task.
Inherited from Task
|
| NamespaceManager | XmlNamespaceManager |
Gets or sets the
System.Xml.XmlNamespaceManager.
Inherited from Element
|
| Parent | Object |
Gets or sets the parent of the element.
Inherited from Element
|
| Project | Project |
Gets or sets the
NAnt.Core.Element.Project to which this element belongs.
Inherited from Element
|
| Properties | PropertyDictionary |
Gets the properties local to this
NAnt.Core.Element and the
NAnt.Core.Element.Project.
Inherited from Element
|
| TargetName | string |
NAnt target to call.
|
| Threshold | Level |
Gets or sets the log threshold for this
NAnt.Core.Task. By
default the threshold of a task is NAnt.Core.Level.Debug,
causing no messages to be filtered in the task itself.
Inherited from Task
|
| UnlessDefined | bool |
Opposite of
NAnt.Core.Task.IfDefined. If false
then the task will be executed; otherwise, skipped. The default is
false.
Inherited from Task
|
| Verbose | bool |
Determines whether the task should report detailed build log messages.
The default is
false.
Inherited from Task
|
| XmlNode | XmlNode |
Gets or sets the XML node of the element.
Inherited from Element
|
Methods
| Name | Value | Summary |
|---|---|---|
| CopyTo |
void |
Copies all instance data of the
NAnt.Core.Element to a given
NAnt.Core.Element.
Inherited from Element
|
| Execute |
void |
Executes the task unless it is skipped.
Inherited from Task
|
| ExecuteTask |
void |
Executes the specified target.
|
| Get |
XmlNode |
Locates the XML node for the specified attribute in either the
configuration section of the extension assembly or the.project.
Inherited from Task
|
| Get |
XmlNode |
Inherited from Element
|
| GetLocation |
Location |
Retrieves the location in the build file where the element is
defined.
Inherited from Element
|
| Initialize |
void |
Makes sure the
NAnt.Core.Tasks.CallTask is not calling its own
parent.
|
| Initialize |
void |
Performs default initialization.
Inherited from Element
|
| Initialize |
Element |
Initializes the build element.
Inherited from Element
static
|
| InitializeElement |
void |
Derived classes should override to this method to provide extra
initialization and validation not covered by the base class.
Inherited from Element
|
| InitializeTask |
void |
Initializes the task.
Inherited from Task
|
| Initialize |
void |
Initializes the configuration of the task using configuration
settings retrieved from the NAnt configuration file.
Inherited from Task
|
| InitializeXml |
void |
Initializes all build attributes and child elements.
Inherited from Element
|
| IsLogEnabledFor |
bool |
Determines whether build output is enabled for the given
NAnt.Core.Level.
Inherited from Task
|
| Log |
void |
Logs a message with the given priority.
Inherited from Task
|
| Log |
void |
Logs a formatted message with the given priority.
Inherited from Task
|
