Summary
- Assembly
- NAnt
.Core .dll - Namespace
- NAnt
.Core .Tasks - Interfaces
- Base Types
-
- Object
- Element
- Task
- ExternalProgramBase
Syntax
[TaskName("exec")]
public class ExecTask : ExternalProgramBase, IConditional
Examples
Ping "nant.sourceforge.net".
<exec program="ping">
<arg value="nant.sourceforge.net" />
</exec>
Execute a java application using IKVM.NET
that requires the
Apache FOP jars, and a set of custom jars.
<path id="fop-classpath">
<pathelement file="${fop.dist.dir}/build/fop.jar" />
<pathelement file="${fop.dist.dir}/lib/xercesImpl-2.2.1.jar" />
<pathelement file="${fop.dist.dir}/lib/avalon-framework-cvs-20020806.jar" />
<pathelement file="${fop.dist.dir}/lib/batik.jar" />
</path>
<exec program="ikvm.exe" useruntimeengine="true">
<arg value="-cp" />
<arg>
<path>
<pathelement dir="conf" />
<path refid="fop-classpath" />
<pathelement file="lib/mylib.jar" />
<pathelement file="lib/otherlib.zip" />
</path>
</arg>
<arg value="org.me.MyProg" />
</exec>
Assuming the base directory of the build file is "c:\ikvm-test" and
the value of the "fop.dist.dir" property is "c:\fop", then the value
of the -cp
argument that is passed toikvm.exe
is
"c:\ikvm-test\conf;c:\fop\build\fop.jar;conf;c:\fop\lib\xercesImpl-2.2.1.jar;c:\fop\lib\avalon-framework-cvs-20020806.jar;c:\fop\lib\batik.jar;c:\ikvm-test\lib\mylib.jar;c:\ikvm-test\lib\otherlib.zip"
on a DOS-based system.
Remarks
Use of nested NAnt.Core.Tasks.ExternalProgramBase.Arguments
element(s)
is advised over the NAnt.Core.Tasks.ExecTask.CommandLineArguments
parameter, as
it supports automatic quoting and can resolve relative to absolute
paths.
Attributes
Type | Description |
---|---|
TaskNameAttribute | Indicates that class should be treated as a task. |
Fields
Name | Constant Value | Summary |
---|---|---|
UnknownExitCode | -1000 |
Defines the exit code that will be returned by
NAnt.Core.Tasks.ExternalProgramBase.ExitCode
if the process could not be started, or did not exit (in time).
Inherited from ExternalProgramBase
static
|
Properties
Name | Value | Summary |
---|---|---|
Arguments | ArgumentCollection |
The command-line arguments for the external program.
Inherited from ExternalProgramBase
|
BaseDirectory | DirectoryInfo |
The directory the program is in.
|
CommandLine | string |
Gets the command-line arguments, separated by spaces.
Inherited from ExternalProgramBase
|
CommandLineArguments | string |
The command-line arguments for the program. These will be
passed as is to the external program. When quoting is necessary,
these must be explicitly set as part of the value. Consider using
nested
NAnt.Core.Tasks.ExternalProgramBase.Arguments elements instead.
|
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
|
EnvironmentSet | EnvironmentSet |
Environment variables to pass to the program.
|
ErrorWriter | TextWriter |
Gets or sets the
System.IO.TextWriter to which error output
of the external program will be written.
Inherited from ExternalProgramBase
|
ExeName | string |
The name of the executable that should be used to launch the
external program.
Inherited from ExternalProgramBase
|
ExitCode | int |
Gets the value that the process specified when it terminated.
Inherited from ExternalProgramBase
|
ExpectedExitCode | int |
Gets or sets the expected exit code.
|
FailOnError | bool |
Determines if task failure stops the build, or is just reported.
The default is
true .
Inherited from Task
|
FileName | string |
The program to execute without command arguments.
|
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
|
Managed | ManagedExecution |
Specifies whether the external program is a managed application
which should be executed using a runtime engine, if configured.
The default is
false .
|
Name | string |
The name of the task.
Inherited from Task
|
NamespaceManager | XmlNamespaceManager |
Gets or sets the
System.Xml.XmlNamespaceManager .
Inherited from Element
|
Output | FileInfo |
The file to which the standard output will be redirected.
|
OutputAppend | bool |
Gets or sets a value indicating whether output should be appended
to the output file. The default is
false .
|
OutputWriter | TextWriter |
Gets or sets the
System.IO.TextWriter to which standard output
messages of the external program will be written.
Inherited from ExternalProgramBase
|
Parent | Object |
Gets or sets the parent of the element.
Inherited from Element
|
ProcessId | int |
Gets the unique identifier for the spawned application.
Inherited from ExternalProgramBase
|
ProcessIdProperty | string |
The name of a property in which the unique identifier of the spawned
application should be stored. Only of interest if
NAnt.Core.Tasks.ExecTask.Spawn
is true .
|
ProgramArguments | string |
Gets the command-line arguments for the external program.
|
ProgramFileName | string |
Gets the filename of the external program to start.
|
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
|
ResultProperty | string |
The name of a property in which the exit code of the program should
be stored. Only of interest if If the exit code of the program is "-1000" then the program could not be started, or did not exit (in time). |
Spawn | bool |
Gets or sets a value indicating whether the application should be
spawned. If you spawn an application, its output will not be logged
by NAnt. The default is
false .
|
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
|
TimeOut | int |
The maximum amount of time the application is allowed to execute,
expressed in milliseconds. Defaults to no time-out.
Inherited from ExternalProgramBase
|
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
|
UseRuntimeEngine | bool |
Specifies whether the external program should be executed using a
runtime engine, if configured. The default is
false .
|
Verbose | bool |
Determines whether the task should report detailed build log messages.
The default is
false .
Inherited from Task
|
WorkingDirectory | DirectoryInfo |
The directory in which the command will be executed.
|
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 external program.
|
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 |
Performs additional checks after the task has been initialized.
|
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
|
PrepareProcess |
void |
Updates the
System.Diagnostics.ProcessStartInfo of the specified
System.Diagnostics.Process .
|
StartProcess |
Process |
Starts the process and handles errors.
Inherited from ExternalProgramBase
|