RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Speed Up Project Delivery with Repeatability : Page 5

Automate high-friction, unpredictable tasks in your environment to regain sanity and achieve a rapid, sustainable pace.


Automated Deployment

Takeaway: Your build product should be deployable to another environment with minimal human interaction. NAnt can really pay off here. Most deployment processes are complicated, conditional, multi-step processes that require a lot of "magic" to come out right. One effective way to address this problem is to keep a master record that explains of how, exactly, the build-and-deploy process works. And the best way to document that process is through the actual code that performs the process. External documents or wikis quickly get out of sync with the real process, and soon become a liability rather than an asset. Using NAnt as your deployment documentation solves two problems at once.

Start by adding a new target to your build.xml file called package (or whatever makes sense to you). It should depend upon the test target to ensure that you don't package a broken build.

The flow of a release target should go something like this:

  1. Build and test the solution.
  2. Create the release folder if it's not already there.
  3. Create a temporary folder under the release folder.
  4. Copy the solution output files to the temporary folder (except for PDB files and other files you don't want in the final release).
  5. Zip up the temp folder's contents into the main release folder.
  6. Delete the temp folder.
A basic package target will look something like the following:

   <target name="package" depends="test">
     <property name="release.dir" 
     <mkdir dir="${release.dir}"/>
     <mkdir dir="${release.dir}/temp"/>
     <copy todir="${release.dir}/temp" flatten="true">
         <include name=
         <exclude name="**/*.pdb"/>
     <zip zipfile="${release.dir}/CoDe.zip">
       <fileset basedir="${release.dir}/temp">
         <include name="**/*"/>
     <delete dir="${release.dir}/temp"/>
Using the package target, you can copy the .zip file to another computer, extract it, and execute it. If your deployment process involves making an installer of some kind, this would be the place to do it.

Obviously this is an extremely simple package target, and most systems will require many more things. I encourage you to look at the list of pre-canned tasks available in NAnt.

NAnt has a sister project known as "NAnt-contrib" that includes even more pre-built tasks for various purposes. NAnt-contrib is a separate project because it includes specialized tasks that are outside the scope of normal NAnt usage, such as Active Directory interaction, BizTalk utilities, FXCop execution, GAC manipulation, and integration with many different source control providers, including Subversion and Microsoft Visual SourceSafe. Check it out, because you will probably be able to use one or more of these tasks.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date