Kiq*_*net 33 c# msbuild iis-7 iis-6 web-deployment
我有Windows Server 2003(IIS 6.0)和Windows Server 2008(IIS 7.0)服务器,我使用MSBuild来部署Web应用程序.
我需要进行安全部署,并执行此操作:
停止IIS 6中的网站(或IIS 7中的应用程序),而不是停止AppPool.
检查网站是否停止; 没跑
如果网站已停止,请执行另一项部署任务.
启动IIS 6(或IIS 7中的应用程序)网站,
我怎样才能做到这一点?
更新:对我来说:IIS6WebSite和IIS6AppPool(以及IIS7),在尝试停止网站或AppPool时是否等待停止状态?
当我执行网站停止操作(或AppPool的停止操作)时,我需要确保100%网站已停止,然后,只有网站停止时,我才能执行其他目标.
Gra*_*mas 46
通过添加引用Microsoft.Web.Administration(可以在X:\Windows\System32\inetsrv或等效的系统中找到),您可以使用IIS7实现对情境的良好管理控制,如下所示:
namespace StackOverflow
{
using System;
using System.Linq;
using Microsoft.Web.Administration;
class Program
{
static void Main(string[] args)
{
var server = new ServerManager();
var site = server.Sites.FirstOrDefault(s => s.Name == "Default Web Site");
if (site != null)
{
//stop the site...
site.Stop();
if (site.State == ObjectState.Stopped)
{
//do deployment tasks...
}
else
{
throw new InvalidOperationException("Could not stop website!");
}
//restart the site...
site.Start();
}
else
{
throw new InvalidOperationException("Could not find website!");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
显然,根据您自己的要求定制它,并通过您的部署构建脚本执行生成的应用程序.
请享用.:)
| 归档时间: |
|
| 查看次数: |
28233 次 |
| 最近记录: |