Home
Products
Forums
Help
Publish Article
Go Freelance

Build and deploy web application project using NANT script

This week I was trying to get automated build of my Asp.Net web application project (WAP) going in Cruise Control using NANT scripts. This was the first WAP project that I was integrating in Cruise Control. During this integration process I ran into some issues that I was not anticipating when i started the mission. This article is an attempt to outline some of those issues and help others to get over them when they come across the similar issue.

Let me first show you what my final script looks like and then I will discuss what different options mean in there and why those options were chosen.

<target name="build" description="Compile Web Site.">
  <exec basedir="."
  program="msbuild.exe"
  commandline=" MySite.csproj /nologo 
  /t:Rebuild
  /t:ResolveReferences;_CopyWebApplication
  /p:OutDir=..\..\deploymentdir\bin\
  /p:WebProjectOutputDir=..\..\deploymentdir\"
  workingdir="."
  failonerror="true" />
</target>
							

Now lets look at various options that have been set here to achieve automated build and copying of ASP.Net web application to folder where we needed to deploy it in production environment.

program
Notice that we have set this value to use MSBUILD instead of ASPNET_COMPILER.exe. This will make sure that your WAP project file is used to compile the application.
commandline
This is where you will specify any command line parameters that you need to set for the build process. You can look at documentation of MSBUILD to see what all command line parameters are available. Lets look at what command like parameters i have used and why they were used.
/t
This is short name for /targets option. This allows you to set the targets that need to be built using MSBUILD. I have set it to Rebuild, ResolveReferences,_CopyWebApplication. This means that web application needs should be rebuilt, resolve all references and then invoke _CopyWebApplication target.
/p
This is short for /property option. This allows you to set key value pairs for project property values. In the above example i have set 2 properties, OutDir and WebProjectOutDir. OutDir property value indicates where the binary files should be copied after compilation. And WebProjectOutputDir is value that is used by _CopyWebApplication target. If you do not specify this value, then default action is to copy web application files into $(OutDir)_PublishedWebsites\$(MSBuildProjectName) folder. This value is specified in C:\Program Files\MSBuild\Microsoft\VisualStudio\v8.0\WebApplications\Microsoft.WebApplication.targets file.

If you have any other properties that you need to set for your project, you can set them through /p option and you will be good to go.

Go Freelance
Home     About us     Contact us    Copyright    Privacy Policy    Return Policy    Advertisers
Copyright © Netomatix