<setenv>

Sets an environment variable or a whole collection of them. Use an empty value attribute to clear a variable.

Note: 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 <exec> task and its nested environment element might be a better option.

Note: Expansion of inline environment variables is performed using the syntax of the current platform. So on Windows platforms using the string %PATH% in the value attribute will result in the value of the PATH variable being expanded in place before the variable is set.

Parameters

Attribute Type Description Required
dir directory The value for a directory-based environment variable. NAnt will convert it to an absolute path. False
file file The value for a file-based environment variable. NAnt will convert it to an absolute filename. False
name string The name of a single Environment variable to set False
path <path> The value for a PATH like environment variable. You can use : or ; as path separators and NAnt will convert it to the platform's local conventions. False
value string The literal value for the environment variable. False
failonerror bool Determines if task failure stops the build, or is just reported. The default is true. False
if bool If true then the task will be executed; otherwise, skipped. The default is true. False
unless bool Opposite of if. If false then the task will be executed; otherwise, skipped. The default is false. False
verbose bool Determines whether the task should report detailed build log messages. The default is false. False

Nested Elements:

<variable>

Represents an environment variable.

Parameters

Attribute Type Description Required
name string The name of the environment variable. True
dir directory The value for a directory-based environment variable. NAnt will convert it to an absolute path. False
file file The value for a file-based environment variable. NAnt will convert it to an absolute filename. False
if bool Indicates if the environment variable should be passed to the external program. If true then the environment variable will be passed; otherwise, skipped. The default is true. False
path <path> The value for a PATH like environment variable. You can use : or ; as path separators and NAnt will convert it to the platform's local conventions. False
unless bool Indicates if the environment variable should not be passed to the external program. If false then the environment variable will be passed; otherwise, skipped. The default is false. False
value string The literal value for the environment variable. False

Nested Elements:

<path>

Sets a single environment variable and treats it like a PATH - ensures the right separator for the local platform is used.

</path>

</variable>

Examples

Requirements

Assembly: NAnt.Core (0.91.4312.0)