is it possible to manage IIS web applications with NAnt? For example stop or start it?
3 Answers
Nant has the servicecontroller task with which you can either stop/start just the Web server or entire IIS, i use it generally to just stop/start the web server.
<servicecontroller action="Stop" service="w3svc"
timeout="10000" verbose="true" />
Documentation available at http://nant.sourceforge.net/release/latest/help/tasks/servicecontroller.html

- 1,824
- 6
- 25
- 32
-
2But I want stop one site, not the whole server. – Andrey Selitsky Feb 25 '09 at 16:13
Maybe you can use exec task to execute
iisreset -stop
iisreset -start
EDIT : And this VBS might help for stopping/starting WebApplications under IIS
Here is the accespted solution to stop a website with nant task on IIS :
<target name="stopSite">
<exec program="cscript.exe">
<arg value="C:\windows\system32\iisweb.vbs" />
<arg value="/stop" />
<arg value="test" />
</exec>
</target>

- 47,715
- 17
- 91
- 122
-
Thank's for reply, but your solution is unsuitable for me. I want stop only one chosen site, not the whole server. – Andrey Selitsky Feb 25 '09 at 14:24
-
I add a new link that shows how to stop/start web site on command line. Hope this helps. – Canavar Feb 25 '09 at 14:32
-
Great, I found solution with your help:
If you like using Powershell either on its own or calling a powershell script through Nant this is a breeze.
IIS:\>Stop-WebAppPool -Name "DefaultAppPool"
IIS:\>Start-WebAppPool -Name "DefaultAppPool"
You can download the snap-in here http://www.iis.net/download/PowerShell
Some Notes on its use: http://technet.microsoft.com/en-us/library/ee790599.aspx
You can also start/stop individual websites.

- 4,362
- 3
- 32
- 44