4

是否可以使用 NAnt 管理 IIS Web 应用程序?比如停止还是启动呢?

4

3 回答 3

7

Nant 有 servicecontroller 任务,您可以使用它停止/启动 Web 服务器或整个 IIS,我通常使用它来停止/启动 Web 服务器。

<servicecontroller action="Stop" service="w3svc" 
   timeout="10000" verbose="true" />

可在http://nant.sourceforge.net/release/latest/help/tasks/servicecontroller.html获得文档

于 2009-02-25T14:38:17.737 回答
4

也许你可以使用exec任务来执行

iisreset -stop
iisreset -start

编辑:这个VBS可能有助于在 IIS 下停止/启动 WebApplications

这是在 IIS 上停止具有 nant 任务的网站的公认解决方案:

<target name="stopSite"> 
  <exec program="cscript.exe"> 
    <arg value="C:\windows\system32\iisweb.vbs" /> 
    <arg value="/stop" /> 
    <arg value="test" /> 
  </exec> 
</target>
于 2009-02-25T14:16:21.500 回答
0

如果您喜欢单独使用 Powershell 或通过 Nant 调用 powershell 脚本,这很容易。

IIS:\>Stop-WebAppPool -Name "DefaultAppPool"
IIS:\>Start-WebAppPool -Name "DefaultAppPool"

您可以在此处下载管理单元 http://www.iis.net/download/PowerShell

关于其使用的一些注意事项: http ://technet.microsoft.com/en-us/library/ee790599.aspx

您还可以启动/停止单个网站。

于 2010-12-27T17:09:46.810 回答