1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml">
4
<meta http-equiv="Content-Language" content="en-ca" />
5
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
<meta name="description" content="Properties" />
7
<link rel="stylesheet" type="text/css" href="../style.css" />
8
<title>NAnt - Properties</title>
11
<table width="100%" border="0" cellspacing="0" cellpadding="2" class="NavBar">
13
<td class="NavBar-Cell">
14
<a title="NAnt home page" href="http://nant.sourceforge.net"><b>NAnt</b></a> <img src="../images/arrow.gif" alt="->" width="13" height="9" />
15
<a href="../index.html">Help</a> <img alt="->" src="../images/arrow.gif" /> <a href="index.html">
16
Fundamentals</a> <img height="9" alt="->" src="../images/arrow.gif" width="13" />
19
<td class="NavBar-Cell" align="right">
26
<h2><a id="contents" />Contents</h2>
28
1 <a href="#introduction">Introduction</a><br />
29
2 <a href="#naming-rules">Naming rules</a><br />
30
3 <a href="#built-in-properties">Built-in Properties</a><br />
31
<div style="margin-left: 20px;">
32
3.1 <a href="#framework-related-properties">Framework related Properties</a><br />
33
3.2 <a href="#platform-related-properties">Platform related Properties</a>
35
4 <a href="#readonly-properties">Read-only Properties</a><br />
36
5 <a href="#global-properties">Global Properties</a><br />
37
6 <a href="#examples">Examples</a><br />
39
<h2><a id="introduction" />1 Introduction</h2>
40
<p>A project can have a set of properties. These might be set in the
41
buildfile by the <a href="../tasks/property.html"><property></a> task, or
42
might be set outside NAnt. A property has a name and a value. Properties
43
may be used in the value of task attributes. This is done by placing the
44
property name between "<code>${</code>" and "<code>}</code>" in the attribute
45
value. Properties may also be used in <a href="expressions.html">expressions</a>.
47
<h2><a id="naming-rules" />2 Naming rules</h2>
48
<p>A property name is a string of the following characters:</p>
51
letters (<code>A-Z</code>, <code>a-z</code>),</li>
53
digits (<code>0-9</code>),</li>
55
underscore characters (<code>_</code>),</li>
57
dash characters (<code>-</code>),</li>
59
dot characters (<code>.</code>),</li>
61
<p>In addition, a valid property name must start with a letter or an underscore and
62
must end with a letter, digit or an uderscore.</p>
63
<p>Examples of valid property names include:</p>
66
<code>propertyname</code></li>
68
<code>property.name.with.dots</code></li>
70
<code>property-name-with-dashes</code></li>
72
<code>property.name-with.both-dots.and-dashes</code></li>
74
<code>__prop---3-erty__</code></li>
76
<code>__prop.1...erty__</code></li>
78
<code>property1</code></li>
80
<code>property1.0</code></li>
82
<code>property2.0.0</code></li>
84
<code>_property-2-1__</code></li>
86
<code>property-1-name_</code></li>
88
<code>property-1.0-name</code></li>
90
<p>The following property names are not valid in NAnt:</p>
93
<code>!@#!@$!@</code> (contains illegal characters)</li>
95
<code>.aaaaa</code> (starts with a dot)</li>
97
<code>-aaaaa</code> (starts with a dash)</li>
99
<code>1aaaaa</code> (starts with a digit)</li>
101
<code>aaaaa.aaa.a.a.a.a-</code> (ends with a dash)</li>
103
<code>aaaaa.aaa.a.a.a.a.</code> (ends with a dot)</li>
105
<h2><a id="built-in-properties" />3 Built-in Properties</h2>
106
<p>NAnt has these built-in properties:</p>
117
<td>nant.version</td>
118
<td><i>Deprecated.</i> The version of NAnt.</td>
121
<td>nant.filename</td>
122
<td><i>Deprecated.</i> The full path to the NAnt assembly.</td>
125
<td>nant.location</td>
126
<td><i>Deprecated.</i> The base directory of the NAnt assembly.</td>
129
<td>nant.project.basedir</td>
130
<td><i>Deprecated.</i> The absolute path of the project's basedir.</td>
133
<td>nant.project.buildfile</td>
134
<td><i>Deprecated.</i> The absolute path of the buildfile.</td>
137
<td>nant.project.name</td>
138
<td><i>Deprecated.</i> The name of the project.</td>
141
<td>nant.project.default</td>
142
<td><i>Deprecated.</i> The name of the project's default target.</td>
145
<td>nant.onsuccess</td>
146
<td>The name of a target to be executed when the build succeeds.</td>
149
<td>nant.onfailure</td>
150
<td>The name of a target to be executed when the build fails.</td>
155
<h3><a id="framework-related-properties" />3.1 Framework related Properties:</h3>
166
<td>nant.settings.currentframework</td>
167
<td>The current target framework, eg. 'net-1.0'.</td>
170
<td>nant.settings.currentframework.description</td>
171
<td><i>Deprecated.</i> Description of the current target framework.</td>
174
<td>nant.settings.currentframework.frameworkdirectory</td>
175
<td><i>Deprecated.</i> The framework directory of the current target framework.</td>
178
<td>nant.settings.currentframework.sdkdirectory</td>
179
<td><i>Deprecated.</i> The framework SDK directory of the current target framework.</td>
182
<td>nant.settings.currentframework.frameworkassemblydirectory</td>
183
<td><i>Deprecated.</i> The framework assembly directory of the current target
187
<td>nant.settings.currentframework.runtimeengine</td>
188
<td><i>Deprecated.</i> The runtime engine of the current target framework if used
194
<h3><a id="platform-related-properties" />3.2 Platform related Properties:</h3>
205
<td>nant.platform.name</td>
206
<td><i>Deprecated.</i> The name of the platform on which NAnt is currently running
207
- either <code>win32</code> or <code>unix</code>.</td>
210
<td>nant.platform.win32</td>
211
<td><i>Deprecated.</i> Holds the value <code>true</code> if NAnt is running on the <code>
212
win32</code> platform; otherwise, <code>false</code>.</td>
215
<td>nant.platform.unix</td>
216
<td><i>Deprecated.</i> Holds the value <code>true</code> if NAnt is running on the <code>
217
unix</code> platform; otherwise, <code>false</code>.</td>
222
<h2><a id="readonly-properties" />4 Read-only Properties</h2>
224
A property can be explicitly marked read-only by setting the
225
"readonly" attribute on the <a href="../tasks/property.html"><property></a>
229
The value of a read-only property cannot be modified after it has been set.
232
When attempting to override a read-only property using the <a href="../tasks/property.html">
233
<property></a> task, the new value will be ignored and a warning
234
message will be output in the build log. Attempting to override read-only
235
properties using any other means (eg. other tasks) will result in a build
238
<p><b>Note:</b> properties set on the command-line are always read-only.</p>
239
<h2><a id="global-properties" />5 Global Properties</h2>
240
<p>Properties that should be accessible to all build files on a system can be
241
defined in the <code><properties></code> node of the NAnt configuration
242
file (<code>NAnt.exe.config</code>).</p>
243
<p>By changing the value of the property in the NAnt configuration file, the
244
updated value will be accessible to all build files on the system:</p>
246
<?xml version="1.0"?>
247
<configuration>
252
<!-- properties defined here are accessible to all build files -->
253
<property name="company.name" value="Foo Ltd." readonly="true" />
256
</configuration>
258
<p>Individual build files can then use this property:</p>
260
<?xml version="1.0"?>
261
<project name="test">
262
<echo message="Company: ${company.name}" />
265
<p>The output of this build is:</p>
267
[echo] Company: Foo Ltd.
269
<h2><a id="example" /> 6 Examples</h2>
270
<p>The following build file demonstrates the use of property expansion:</p>
272
<?xml version="1.0"?>
273
<project name="Property Test" default="test" basedir=".">
274
<property name="project.name" value="PropertyTest"/>
275
<property name="project.version" value="1.0.0"/>
276
<target name="test">
277
<echo message="Building ${project.name}-${project.version}"/>
281
<p>The output of this build is:</p>
283
[echo] Building PropertyTest-1.0.0
285
<p>The following build file demonstrates the use of properties in <a href="expressions.html">
286
expressions</a>. It evaluates the length of the property <code>project.name</code>
289
<?xml version="1.0"?>
290
<project name="Expression Test" default="test" basedir=".">
291
<property name="project.name" value="Expression Test"/>
292
<target name="test">
293
<echo message="Project name consists of ${string::get-length(project.name)} characters."/>
297
<p>The output of this build is:</p>
299
[echo] Project name consists of 15 characters.
304
<a href="../tasks/property.html"><property></a>
307
<a href="../tasks/sysinfo.html"><sysinfo></a>
310
<a href="../tasks/tstamp.html"><tstamp></a>