Home > Development > NAnt Episode 1 – Setup and Compilation

NAnt Episode 1 – Setup and Compilation

Okay. We are looking at build scripts. We are just going to get setup in this post and getting it building using msbuild.

Lets setup the project structure…
Create a project called NAntBuildDemo, make it a console application for testing purposes. Now create a file called NAntDemoBuild.build in the same folder as the solution folder.

NAnt has a main project definition which you name and the has whats called targets, basically a group of tasks to run together. With targets you can have them depend on other targets which is important as usually a compile target will depend on a clean target. Sounds like Make of old but its much richer.

Here is the XML…

<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://nant.sf.net/release/0.86-beta1/nant.xsd" name="NAntBuildDemo" default="compile">
  <property name="source.dir" value="NAntDemoBuild"/>
  <property name="solution.file" value="NAntDemoBuild.sln" />
  <target name="compile">
    <echo message="Compilation has started: ${framework::get-framework-directory(nant.settings.currentframework)}\msbuild.exe"/>
        program="${framework::get-framework-directory(nant.settings.currentframework)}\msbuild.exe "
        commandline=" ${solution.file}  /nologo /t:Rebuild /p:Configuration=Debug" />
    <echo message="Compilation has completed"/>

You can see we have a also have declared properties. These are basically variable which you can use else where using the ${propertyname} syntax.


Categories: Development Tags: , , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: