Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the application pool through a Web Deployment Project

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?

like image 394
Rob Avatar asked Oct 03 '08 14:10

Rob


2 Answers

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

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:

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.

like image 156
Zachary Yates Avatar answered Nov 08 '22 22:11

Zachary Yates


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

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.

like image 31
Sunny Milenov Avatar answered Nov 08 '22 20:11

Sunny Milenov