Sets an environment variable or a whole collection of them. Use an empty
NAnt.Core.Tasks.SetEnvTask.LiteralValue
attribute to clear a variable.
Variables will be set for the current NAnt process and all child
processes that NAnt spawns (compilers, shell tools, etc). If the
intention is to only set a variable for a single child process, then
using the
NAnt.Core.Tasks.ExecTask
and its nested NAnt.Core.Tasks.ExecTask.EnvironmentSet
element might be a better option.
Expansion of inline environment variables is performed using the syntax
of the current platform. So on Windows platforms using the string %PATH%
in the
NAnt.Core.Tasks.SetEnvTask.LiteralValue
attribute will result in the value of
the PATH variable being expanded in place before the variable is set.
Parameters
Nested elements
<variable>
Gets or sets the environment variables.
Parameters
Nested elements
<variable>
Examples
Set the MONO_PATH environment variable on a *nix platform.
<setenv name=="MONO_PATH" value="/home/jimbob/dev/foo:%MONO_PATH%"/>
Set a collection of environment variables. Note the nested variable used to set var3.
<setenv>
<variable name="var1" value="value2" />
<variable name="var2" value="value2" />
<variable name="var3" value="value3:%var2%" />
</setenv>
Set environment variables using nested path elements.
<path id="build.path">
<pathelement dir="c:/windows" />
<pathelement dir="c:/cygwin/usr/local/bin" />
</path>
<setenv>
<variable name="build_path" >
<path refid="build.path" />
</variable>
<variable name="path2">
<path>
<pathelement dir="c:/windows" />
<pathelement dir="c:/cygwin/usr/local/bin" />
</path>
</variable>
</setenv>
Requirements
- Assembly
- NAnt
.Core .dll - Namespace
-
NAnt
.Core .Tasks