NAnt SDK Documentation - v0.92

ExecTask Class

Executes a system command.

For a list of all members of this type, see ExecTask Members.

System.Object
   NAnt.Core.Element
      NAnt.Core.Task
         NAnt.Core.Tasks.ExternalProgramBase
            NAnt.Core.Tasks.ExecTask

[Visual Basic]
<TaskName(Name:="exec")>
Public Class ExecTask
    Inherits ExternalProgramBase
[C#]
[TaskName(Name="exec")]
public class ExecTask : ExternalProgramBase

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

Use of nested Arguments element(s) is advised over the CommandLineArguments parameter, as it supports automatic quoting and can resolve relative to absolute paths.

Example

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.

Requirements

Namespace: NAnt.Core.Tasks

Assembly: NAnt.Core (in NAnt.Core.dll)

See Also

ExecTask Members | NAnt.Core.Tasks Namespace