[ Easy Way :
Open a dos prompt, and go to c:\Projects\BuildingSolution
Run c:\devtools\nant\bin\nant.exe -buildfile:firstbuild.guild.xml
]
The next step is to create the first build file. Start by grabbing the starter script from the NAnt help site [AJ2]and changing a few of the defaults. Review the BuildingSolution1.build file to see the entire build file.
If using VS .NET to edit NAnt files, here's a tip for adding NAnt specific intellisense to the IDE. Copy the .xsd file from c:\devtools\nant\schema and paste it into C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml.
Now create your build file in the solution directory and name it your solution name with the extension .build. Open the file with VS .NET. In the properties window for the build file, you should be able to choose the NAnt schema. This will enable the intellisense.
Now make the following changes to the file:
- Create a new property for Solution.Filename and set it to the filename of your solution.
- Change the build task from using the <csc task to using the <solution task. The solution task will analyze the solution file and build projects in the correct orderand will set up the proper references.
FirstBuild.Build:
<?xml version="1.0"?>
<project name="BuildingSolution" default="build" basedir="." xmlns="http://nant.sf.net/schemas/nant-0.85.win32.net-1.0.xsd">
<description>This is a sample build file to be used for the
BuildingSolution sample</description>
<!--
********** -->
<!--
Properties -->
<!--
Solution.Filename represents the filename of the solution to build -->
<property name="Solution.Filename" value="C:\projects\BuildingSolution\BuildingSolution.sln"/>
<property name="Solution.Configuration" value="DEBUG"/>
<property name="Build.OutputFolder" value="c:\builds\buildingsolution\"/>
<!--
End Properties -->
<!--
******* -->
<!--
Targets -->
<!--
Clean target will delete the current version -->
<target name="clean" description="remove all
generated files">
<delete>
<fileset basedir="${Build.OutputFolder}Latest\">
<includes name="*.*"/>
</fileset>
</delete>
</target>
<!--
build will trigger main build -->
<target name="build" description="compiles
the source code">
<call target="clean"/>
<solution solutionfile="${Solution.Filename}" outputdir="${Build.OutputFolder}latest\" configuration="${Solution.Configuration}"/>
</target>
<!--
End Targets -->
</project>
Shell out to a DOS prompt and go to the directory with the build file. Type in c:\devtools\nant\bin\nant.exe -buildfile:firstbuild.build.xml and watch the first build. You can see the product of the build in c:\builds\buildsingsolution\Latest.