After read previous post, I guess you will feel that nant is wonderful. Because the code is very less. Perfect!
But for Q, it is not.
Q heard that .Net had ported to Linux, So he want to use NAnt to build his project in linux.
Q installed mono, then installed NAnt.
The installation of NAnt in linux is easy, just unzip it, rename it to nant and put it in /opt. (/opt/nant.)
Q copied whole project to Linux home directory, and modify the following line in the build file
<property name="nant.settings.currentframework" value="net-1.1"/>
To
<property name="nant.settings.currentframework" value="mono-1.0"/>
This line tell NAnt should switch compile environment to mono before building.
Then enter the following line:
$mono /opt/nant/bin/NAnt.exe
And NAnt said,
Invalid element <solution>. Unknown task or datatype
Q was sliently crying to accept this fact, he know he should learn more for coding build file.
A NAnt build actually is a XML file, the basic element is
project, project contains
target and
property, and target contains
tasks.
Here is an empty build file:
<
?xml
version="1.0"?>
<project
name="dnsedu" default=
"build">
<property
name="nant.settings.currentframework"
value="net-1.1"/
>
<target
name="build" description=
"Default build target" depends=
"dnsedu">
<
/target>
<
/project>
There are lots of tasks provided by NAnt.
You can refer to the official site:
Task Reference。
Beside basic commands: csc, vbc, cl, al, ilasm, resgen, NAnt also provide these tasks: copy, cvs, mail, nunit ... and etc.
I think these tasks are enough to code a powerful build file.
Now let's rewrite the build file in previous post, and we will use the 2 tasks: csc, mkdir. (I suppose that you use c#)
<project name="your_project" default="build">
<property name="nant.settings.currentframework" value="mono-1.0"/>
<property name="debug" value="false"/>
<target name="build">
<mkdir dir="bin" unless="${directory::exists('bin')}" />
<csc target="winexe" output="bin/your_project.exe" debug="${debug}">
<sources>
<include name="*.cs"/>
</sources>
<references>
<include name="System.Drawing.dll" />
<include name="System.Data.dll" />
<include name="System.Windows.Forms.dll"/>
</references>
<resources>
<include name="*.resx"/>
</resources>
</csc>
</target>
</project>
mkdir task: Here I use
unless attribute, it means "if not". So this line means if specified directory is not existed, make it. If you want to know more, you can refer to
Function Reference.
In csc tasks, you need to specify the
target,
output and
debug information.
Inside csc tasks, you need to specify references, sources and resources.
That's easy, right?
These are the basic things, next time let's talk about Web Application.