During the Visual Studio 2010 Web Application and Web Service deployment the prior setting of the application pool name is lost. The installer does not assign the correct application pool to the virtual directory, it will be assigned to the Default Application Pool.
If different .NET versions are assigned to the same application pool, the older .NET applications stop working.
To handle this problem in the VS 2010 msi file follow the steps below.
- Remote desktop into the web server and in the IIS manager create an application pool for your web application.
- Save the following program as SetAppPool.vbs to a common location in your file structure
' Sets the Application Pool of the Virtual Directory
' Usage:
' Right click on the Web Setup project
' Select Add, File
' Select C:\TFS\HALTeam\Other\Deployment_Tools\SetAppPool.vbs
' Right click on the Web Setup project
' Select View, Custom Actions
' Right click on Commit and select "Add Custom Action"
' Select the SetAppPool.vbs file in the Web Application Folder
' In the Properties window of SetAppPool.vbs enter the CustomActionData:
' Example: /vdir:HALGraphicUpload /appPool:HALGraphicUpload
Option Explicit
Dim customActionData, customActionArray, vdirName, appPool, vdirObj
' Read the CustomActionData of the Installer
customActionData = Session.Property("CustomActionData")
' Parse the data from the CustomActionData
customActionArray = Split(customActionData) ' Splits by the space
vdirName = Replace(customActionArray(0), "/vdir:", "")
appPool = Replace(customActionArray(1), "/appPool:", "")
' Set the Application Pool property of the Virtual Directory
set vdirObj=GetObject("IIS://localhost/W3svc/1/Root/" & vdirName)
vdirObj.Put "AppPoolId", appPool
vdirObj.SetInfo
- Add the SetAppPool.vbs file to the Setup Project
- Right click the setup project
- Select “View”, “File System”
- On the left side right click the “Web Application Folder” and select “Add”, “File…”
- Browse to the “SetAppPool.vbs” file
- Add a custom action to the setup project
- Right click the setup project
- Select “View”, “Custom Actions”
- Right click on “Commit” and select “Add Custom Action”
- Double click the “Web Application Folder”
- Select “SetAppPool.vbs” and click the “OK” button
- On the left side of the screen right click”SetAppPool.vbs” and select “Properties Window”
- Enter the following into the CustomActionData field
/vdir:YOUR_VIRTUAL_DIRECTORY_NAME /appPool:YOUR_APPLICATION_POOL_NAME
(make sure there is only one space before /appPool and there are no other spaces and quotes in the text)