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

Rob*_*Rob 11 c# deployment windows-installer asp.net-2.0

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

Zac*_*tes 12

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

你问的问题在'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
Run Code Online (Sandbox Code Playgroud)

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