When I worked at Principal, we used Ant a lot for building our JARs and EARs against our code repository. Also, we used to aid the already tideous EAR deployment process. I've known of NAnt for quite some time, but never actually played with it...My reasoning was...why should I? I have VS.NET!
One of my 'New Year's Resolutions' was to get more in-touch with .NET (abstract concepts, languages, CLR) and .NET Related tools (aside VS.NET). Thus far, I have played with NUnit and as I suspect it, I picked up rather quickly thanks to my previous JUnit exposure. So tonite, before studying for my 70-320 MSCD exam, I played with NAnt. After a couple minutes of reading the docs, this is what I came up with:
project.build
----------------
<?xml version="1.0"?>
<PROJECT basedir="." default="build" name="Build Test">
<DESCRIPTION>First NAnt Test Build</DESCRIPTION>
<property name="debug" value="false"></property>
<TARGET name="clean" description="Clear all the files">
<DELETE failonerror="false" file="HelloWorld.exe" />
<DELETE failonerror="false" file="HelloWorld.pdb" />
</TARGET>
<TARGET name="build" description="Compile the exec">
<CSC debug="${debug}" output="HelloWorld.exe" target="exe">
<SOURCES>
<INCLUDE name="Hello.cs" />
</SOURCES>
</CSC>
<CALL target="run" />
</TARGET>
<TARGET name="run" description="Runs the compiled program">
<ECHO>Running the compiled file:</ECHO>
<EXEC failonerror="false" program="HelloWorld.exe">
<ARG value="param1" />
<ARG value="param2" />
</EXEC>
</TARGET>
</PROJECT>
NantTest.cs
--------------
using System;
namespace NAnt
{
class Test
{
static void Main(string[] args)
{
Console.WriteLine("I was compiled and ran using NAnt!");
if(args != null)
foreach(string s in args)
Console.WriteLine("param: {0}",s);
}
}
}
This code is very simple as you can see, but it's kinda nice to have a method to automate the building of large applications you do not have VS.NET handy. I'm going to start writing my examples with their corresponding NAnt built files.