通过Web部署项目更改应用程序池

时间:2022-08-26 18:44:36

Is there a way to configure a Visual Studio 2005 Web Deployment Project to install an application into a named Application Pool rather than the default app pool for a given web site?

有没有办法配置Visual Studio 2005 Web部署项目以将应用程序安装到命名的应用程序池而不是给定网站的默认应用程序池?

2 个解决方案

#1


12  

There is a good article describing custom actions here: ScottGu's Blog

这里有一篇很好的文章描述了自定义操作:ScottGu的博客

The question you asked is answered about halfway through the comments by 'Ryan', unfortunately it's in VB, but it shouldn't be hard to translate:

你问的问题是在'Ryan'评论的中间回答的,不幸的是它在VB中,但翻译起来应该不难:

Private Sub assignApplicationPool(ByVal WebSite As String, ByVal Vdir As String, ByVal appPool As String)
   Try
     Dim IISVdir As New DirectoryEntry(String.Format("IIS://{0}/W3SVC/1/Root/{1}", WebSite, Vdir))
     IISVdir.Properties.Item("AppPoolId").Item(0) = appPool
     IISVdir.CommitChanges()
   Catch ex As Exception
     Throw ex
   End Try
 End Sub

 Private strServer As String = "localhost"
 Private strRootSubPath As String = "/W3SVC/1/Root"
 Private strSchema As String = "IIsWebVirtualDir"
 Public Overrides Sub Install(ByVal stateSaver As IDictionary)
   MyBase.Install(stateSaver)
   Try
     Dim webAppName As String = MyBase.Context.Parameters.Item("TARGETVDIR").ToString
     Dim vdirName As String = MyBase.Context.Parameters.Item("COMMONVDIR").ToString
     Me.assignApplicationPool(Me.strServer, MyBase.Context.Parameters.Item("TARGETVDIR").ToString, MyBase.Context.Parameters.Item("APPPOOL").ToString)
   Catch ex As Exception
     Throw ex
   End Try
 End Sub

...Where APPPOOL is supplied as an argument in the Custom Action.

... APPPOOL在自定义操作中作为参数提供。

#2


3  

You can use a CustomAction to modify IIS during deployment, Here is an article how to do it: Modifying Internet Information Services During Deployment with Custom Actions

您可以使用CustomAction在部署期间修改IIS,以下是一篇如何执行此操作的文章:使用自定义操作部署期间修改Internet信息服务

The example in the article is in VB.Net, and does not show explicitly how to change the Application Pool, but it should be easy to figure it out.

本文中的示例是在VB.Net中,并未明确显示如何更改应用程序池,但应该很容易弄清楚。

#1


12  

There is a good article describing custom actions here: ScottGu's Blog

这里有一篇很好的文章描述了自定义操作:ScottGu的博客

The question you asked is answered about halfway through the comments by 'Ryan', unfortunately it's in VB, but it shouldn't be hard to translate:

你问的问题是在'Ryan'评论的中间回答的,不幸的是它在VB中,但翻译起来应该不难:

Private Sub assignApplicationPool(ByVal WebSite As String, ByVal Vdir As String, ByVal appPool As String)
   Try
     Dim IISVdir As New DirectoryEntry(String.Format("IIS://{0}/W3SVC/1/Root/{1}", WebSite, Vdir))
     IISVdir.Properties.Item("AppPoolId").Item(0) = appPool
     IISVdir.CommitChanges()
   Catch ex As Exception
     Throw ex
   End Try
 End Sub

 Private strServer As String = "localhost"
 Private strRootSubPath As String = "/W3SVC/1/Root"
 Private strSchema As String = "IIsWebVirtualDir"
 Public Overrides Sub Install(ByVal stateSaver As IDictionary)
   MyBase.Install(stateSaver)
   Try
     Dim webAppName As String = MyBase.Context.Parameters.Item("TARGETVDIR").ToString
     Dim vdirName As String = MyBase.Context.Parameters.Item("COMMONVDIR").ToString
     Me.assignApplicationPool(Me.strServer, MyBase.Context.Parameters.Item("TARGETVDIR").ToString, MyBase.Context.Parameters.Item("APPPOOL").ToString)
   Catch ex As Exception
     Throw ex
   End Try
 End Sub

...Where APPPOOL is supplied as an argument in the Custom Action.

... APPPOOL在自定义操作中作为参数提供。

#2


3  

You can use a CustomAction to modify IIS during deployment, Here is an article how to do it: Modifying Internet Information Services During Deployment with Custom Actions

您可以使用CustomAction在部署期间修改IIS,以下是一篇如何执行此操作的文章:使用自定义操作部署期间修改Internet信息服务

The example in the article is in VB.Net, and does not show explicitly how to change the Application Pool, but it should be easy to figure it out.

本文中的示例是在VB.Net中,并未明确显示如何更改应用程序池,但应该很容易弄清楚。