Wednesday, September 08, 2004

Building Web Applications with NAnt (ASP.NET)

NAnt allows you to build web applications from solution files when you do not have Visual Studio installed (or even when you do). To do so you need to install NAnt into a new directory (e.g. C:\NAnt\). After doing this add C:\NAnt\bin\ to your PATH (via System Properties, Advanced, Environment Variables, System Variables). Also add the path to the vbc/csc compilers (if not already there - C:\WINNT\Microsoft.NET\Framework\v1.1.4322\;C:\NAnt\bin\). To then compile the solution, add WebProjectName.build to the same folder as the solution (i.e. C:\Inetpub\wwwroot\WebProjectName\) and add the following to it:

<project name="WebProjectName">
	<property name="nant.settings.currentframework" value="net-1.1"/>
	<property name="Host" value="http://localhost" />
	<property name="Path" value="c:\inetpub\wwwroot" />
	<property name="WebProjectName.Host" value="${Host}/WebProjectName/WebProjectName.vbproj" />
	<property name="WebProjectName.Path" value="${Path}\WebProjectName\WebProjectName.vbproj" />
	<solution solutionfile="WebProjectName.sln" configuration="Release" >
		<webmap>
			<map url="${WebProjectName.Host}" path="${WebProjectName.Path}" />
		</webmap>
	</solution>
</project>

After saving the file, navigate to the folder using the command prompt
Start
Run
cmd
cd C:\Inetpub\wwwroot\WebProjectName\
nant.

To make things easier, you can add a Command Prompt Here (instructions, alternative download) shortcut to Windows Explorer.

No comments: