1
<?
xml version="1.0"
?>
2 < project name ="Hello World" default ="build" basedir ="." >
3 < description >The Hello World of build files. </ description >
4 < property name ="debug" value ="true" overwrite ="false" />
5 < target name ="clean" description ="remove all generated files" >
6 < delete file ="HelloWorld.exe" failonerror ="false" />
7 < delete file ="HelloWorld.pdb" failonerror ="false" />
8 </ target >
9 < target name ="build" description ="compiles the source code" >
10 < csc target ="exe" output ="HelloWorld.exe" debug ="${debug}" >
11 < sources >
12 < includes name ="HelloWorld.cs" />
13 </ sources >
14 </ csc >
15 </ target >
16 </ project >
2 < project name ="Hello World" default ="build" basedir ="." >
3 < description >The Hello World of build files. </ description >
4 < property name ="debug" value ="true" overwrite ="false" />
5 < target name ="clean" description ="remove all generated files" >
6 < delete file ="HelloWorld.exe" failonerror ="false" />
7 < delete file ="HelloWorld.pdb" failonerror ="false" />
8 </ target >
9 < target name ="build" description ="compiles the source code" >
10 < csc target ="exe" output ="HelloWorld.exe" debug ="${debug}" >
11 < sources >
12 < includes name ="HelloWorld.cs" />
13 </ sources >
14 </ csc >
15 </ target >
16 </ project >
1. Project
属性 | 描述 | 必须? |
name | project的名称 | No |
default | 当在命令行中运行,没有提供运行那个target的时候,默认执行的target | No |
basedir | 执行的基于路径,没有指定的话,默认是该配置文件的父目录 | No |
2. Targets
属性 | 描述 | 必须? |
name | target名称 | Yes |
depends | 依赖于那个其它的target | No |
if | 当if条件符合时,才会执行 | No |
unless | 当条件符合时,忽略执行 | No |
description | 描述 | No |
3. Task
Task就是一块可执行的代码
Tasks的结构:
<name attribute1="value1" attribute2="value2" ... />
具体的task类型可以访问这里: http://nant.sourceforge.net/release/latest/help/tasks/
加载扩展
上面的task类型也许不能够满足你的需求,比如svn取代码,这个时候你需要一些其它的扩展。
扩展有4类, Tasks, Filters, Functions, Global Types
这里有NAnt常用的扩展, 下载地址:http://nantcontrib.sourceforge.net/nightly/latest/nantcontrib-bin.zip