NAnt
Help
Task Reference
<setenv> |
v0.85-nightly-2005-10-11 |
[This is preliminary documentation and subject to change.]
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.
| 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 |
Represents an environment variable.
| 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 |
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>