是否有一种方法可以配置Visual Studio 2005 Web Deployment Project,使其将应用程序安装到指定的应用程序池而不是给定Web站点的默认应用程序池中?
是否有一种方法可以配置Visual Studio 2005 Web Deployment Project,使其将应用程序安装到指定的应用程序池而不是给定Web站点的默认应用程序池中?
这里有一篇很好的文章介绍如何自定义操作: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
...在自定义操作中,APPOOL作为参数提供。