NAnt学习笔记(1) -- NAnt的配置文件结构和一个简单的NAnt例子
2012-04-22 23:14 JustRun 阅读(511) 评论(0) 编辑 收藏 举报NAnt运行自动构建依据的是xml格式的.build文件。
一个完整的build文件由一个project和多个target组成。每个target有可以包含多个task。
下面是一个编译Hello World项目的NAnt配置文件:
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>
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个target, 第一个target是clean, 删除上次编译生成的文件,第二个是build, 生成新的文件。

本文基于署名 2.5 中国大陆许可协议发布,欢迎转载,演绎或用于商业目的,但是必须保留本文的署名justrun(包含链接)。如您有任何疑问或者授权方面的协商,请给我留言。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探