<project name="test" default="deploy" basedir="." xmlns="http://nant.sf.net/schemas/nant.xsd [6]">
<description>Precompiles and zips a test project</description>
<property name="debug" value="true" overwrite="true" />
<!-- The target directory where the application will be deployed and the zip file created -->
<property name="targetDirectory" value="." overwrite="false" />
<!-- The temporary directory where the web application will be precompiled -->
<property name="deployTarget" value="${path::combine(path::get-full-path(targetDirectory), 'deploy')}" overwrite="true" />
<!-- The virtual directory that the web application resides in -->
<property name="virtualDirectory" value="webApplication" overwrite="true" />
<!-- The name of the zip file to create when zipping the deployed web application -->
<property name="deployZipFilename" value="webApplication.zip" overwrite="true" />
<!-- The location where the zip file will be created -->
<property name="deployZipFileLocation" value="${path::combine(path::get-full-path(targetDirectory), deployZipFilename)}" overwrite="true" />
<!-- The location of the .NET Framework directory (for version 2) -->
<property name="dotnetLocation" value="${framework::get-framework-directory('net-2.0')}" overwrite="true" />
<!-- 'clean' target deletes the previously created zip file and deploy directory -->
<target name="clean" description="Remove all generated files">
<!-- Delete the existing zip file -->
<delete file="${deployZipFileLocation}" if="${file::exists(deployZipFileLocation)}" />
<!-- Delete the existing deploy directory -->
<delete dir="${deployTarget}" if="${directory::exists(deployTarget)}" />
</target>
<!-- 'build' target precompiles this ASP.Net application into the deployTarget directory -->
<target name="deploy" description="Precompiles the web application and creates a zip file for it" depends="clean">
<!-- Precompile the web application with the built-in .NET utility -->
<exec
basedir="."
program="${dotnetLocation}\aspnet_compiler.exe"
commandline="-nologo -fixednames -v ${virtualDirectory} "${deployTarget}""
workingdir="."
failonerror="true" />
<!-- Clean up the "deployTarget" directory -->
<delete>
<fileset>
<!-- Delete any visual studio related files -->
<include name="${deployTarget}/*.TempSolution" />
<include name="${deployTarget}/**/*.scc" />
<include name="${deployTarget}/**/*.resx" />
<include name="${deployTarget}/**/*.txt" />
<include name="${deployTarget}/**/*.db" />
<include name="${deployTarget}/**/*.vssscc" />
<!-- Delete all the files in the upload and files directory -->
<include name="${deployTarget}/upload/**/*" />
<include name="${deployTarget}/files/**/*" />
</fileset>
</delete>
<!-- Create a zip file from precompiled web application -->
<zip zipfile="${deployZipFileLocation}" includeemptydirs="true">
<fileset basedir="${deployTarget}">
<include name="**/*" />
</fileset>
</zip>
<!-- delete the deployTarget directory -->
<delete dir="${deployTarget}" />
</target>
</project>
Links:
[1] http://en.wikipedia.org/wiki/Build_tool
[2] http://prdownloads.sourceforge.net/nant/nant-0.85-bin.zip?download
[3] http://prdownloads.sourceforge.net/nantcontrib/nantcontrib-0.85-bin.zip?download
[4] http://nant.sourceforge.net/release/latest/help/tasks/
[5] http://nantcontrib.sourceforge.net/release/latest/help/tasks/
[6] http://nant.sf.net/schemas/nant.xsd