I have recently need to script starting and stopping sites using NAnt. I know there is a lot of buzz around powershell and rake at the time, but i'm still using NAnt in my deployment script. In IIS 6 there were some vb scripts available to perform actions against the IIS using scripts. These scripts has been more or less been replace with powershell commandlets in IIS 7.x. These commandlets uses the Microsoft.Web.Administration.dll to perform the same actions in a more decent manner. Since i'm still using NAnt, i've added a extensions library on github with 2 tasks. IISSiteTask can start and stop sites on on the the local or remote machine IISSiteStatusTask is used to check the current iis status (stopped, started etc) Getting started 1. Download the source from github 2. Open the solution in Visual Studio 2010 and compile the solution 3. Copy the JarleF.NAnt.Tasks.dll into your bin folder of your NAnt installation To check a sites current status add the following markup <iissitestatus machine="localhost" sitename="default web site" propertyname="sitestatus" /><echo message="Site status: ${sitestatus}" />
To stop a site add the following markup
<iissite machine="localhost" sitename="Default Web Site" action="stop" />
And to start a site add the following markup
<iissite machine="localhost" sitename="Default Web Site" action="start" />