Click here to Skip to main content
15,861,125 members
Articles / Web Development / IIS
Article

Specify a different location for Virtual Directories in Web Setup Projects

Rate me:
Please Sign up or sign in to vote.
4.86/5 (21 votes)
16 Oct 2006CPOL5 min read 257.1K   1.1K   71   62
HowTo: Enhance the Installation Address UI dialog in a Visual Studio 2005 Web Setup Project so that the user can select a different physical path for the Virtual Directory installation.

Introduction

When generating an MSI installer with Visual Studio 2005 through a Web Setup Project, there is no possibility to specify the physical path of the Virtual Directory that is created. The location defaults to a subdirectory below the root of the website (typically, this home directory is 'C:\Inetpub\wwwroot').

The only fields provided by the Installation Address dialog box are 'Site' and 'Virtual Directory':

Installation Address Dialog before modification

I decided to enhance this dialog box so that it has the option to specify a different physical location for the Virtual Directory.

The easiest way to accomplish this would be to create a regular Setup Project in Visual Studio, and then implement a custom Installer class that creates the Virtual Directory in the proper location (by passing it the TARGETDIR from the Setup Project). Finally, I would then add the Installer class as a Custom Action in the Setup Project and compile it.

However, there were two reasons why I decided to implement this functionality in a Web Setup Project instead:

  1. I already spent a considerable amount of time creating the Web Setup Project, and I didn't want to start all over again.
  2. I did not want to lose the option to select a website, or implement this in a regular Setup Project.

The implementation cannot be carried out solely by using Visual Studio. These are the steps that needed to be taken:

  • Create the MSI by compiling the Web Setup Project in Visual Studio 2005.
  • Use Orca.exe (from the Microsoft Platform SDK) to extend the Installation Address dialog box.
  • Save the extension as an MSI transform and then apply this transform to the original MSI file.

The compilation of the Web Setup Project in Visual Studio is easy. Let's elaborate a bit on the last two steps.

Modifying the MSI with Orca.exe

Orca.exe provides a graphical user interface which lets you edit Windows Installer tables directly. It is part of the Microsoft Platform SDK for Windows 2003 Server R2. First, install the SDK, then run Orca.msi which is in the /Bin directory of the SDK.

Start Orca.exe. Before editing any tables, make sure to mark the checkbox 'Copy embedded streams during 'Save As'' in 'Tools > Options > Database'. If you forget this step, you will get a nasty "Error 2356: Couldn't locate cabinet in stream" error when running your modified MSI.

In Orca, you'll need to add some rows to the 'Control' and 'ControlEvent' tables and make some slight modifications to existing rows. The changes then need to be saved as an MSI Transform file, so that they can be easily re-applied to any subsequent MSIs that are built with Visual Studio.

First, select 'Transform > New Transform' from the menu, to start recording changes for our Tranform. Now, let's start with the modifications to the Control table. The dialog we want to modify is named 'WebFolderForm', and we want to add a Label, a TextBox, and a Browse button to it. This is achieved by adding the following three rows to the table (Ctrl+R):

Rows to be added to the 'Controls' table

(Note: Due to size restrictions, I split all table screenshots in two parts.)

The only other modification in this table should be to change the 'Control Next' cell of the row that specifies the VDirEdit textbox. Change the value from 'Cancel' to 'InstallLabel':

Modification to existing rows in the 'Control' table

These changes causes the Installation Address dialog box to look like this:

This is how the Installation Address Dialog looks after the modifications

The Browse button is not yet functional. For that, we need to modify the ControlEvent table. Add the following two rows to this table:

Modifications to the 'ControlEvent' table for SelectFolderDialog functionality

The SelectFolderDialog is already available in the MSI database. The above two rows make sure that the Browse button fires up this dialog and that the selected folder-location is stored in the TARGETDIR property. These are all modifications. Now, save the Transform to disk by selecting 'Transform > Close Transform'. Orca saves a file with a .mst extension that can be used in future to extend MSI packages that are created by Visual Studio.

It is very easy to apply a Transform to an MSI database. Just open the MSI with Orca, then apply the transformation by choosing 'Transform > Apply Transform...' from the menu. To finish, save the modified MSI by choosing 'File > Save Transformed As...'. To avoid some problems, it would be a good idea to specify 'Transform Properties...' from the 'Transform' menu before saving the transformed MSI. Check the following three checkboxes: 'Same Language', 'Same Product Code', and 'Same Upgrade Code'.

Additional Steps

The contents of the MSI tables is generated by Visual Studio when creating the installer. There might be some variations in the generated code which require additional steps to make the solution work properly.

Visual Studio may insert a couple of Custom Actions, which reset the TARGETDIR to its original location. They are run when clicking the 'Next' button on the WebFolderForm. If this is the case, you'll see the following row in the ControlEvent table:

WebFolderFormNextDoActionWEBCA_EvaluateURLsMB11

This specifies that the Custom Action WEBCA_EvaluateURLsMB should be run on clicking 'Next'. In the 'Ordering' column, this action has a higher order number than SetTargetPath which sets the TARGETDIR. Changing the ordering, however, is not sufficient, because in the InstallExecuteSequence, there is a call for the Custom Action WEBCA_EvaluateURLs, and in the InstallUISequence table finally resides the WEBCA_EvaluateURLsNoFail Custom Action. Removing these from all three tables will fix the problem. Another possibility is to remove these actions altogether by removing the corresponding rows from the CustomAction table.

I am not sure what the function of these Custom Actions is, since they are undocumented. They are inserted by Visual Studio in a binary stream in the MSI named MSVBDPCADLL (contains MSVBDPCA.DLL). Removing them did not negatively influence the installation process as far as I could see.

Specify the default installation directory

After the removal of the Custom Actions, the default installation directory is no longer initialized to a path below your web server. It is easy to install to a directory like [ProgramFilesFolder][Manufacturer]\[ProductName] by adding a couple of extra rows to the MSI (which is the default for regular Setup projects).

Add this row to the CustomAction table:

DIRCA_TARGETDIR307TARGETDIR[ProgramFilesFolder][Manufacturer]\[ProductName]

and then the following rows to both the InstallExecuteSequence and InstallUISequence tables:

DIRCA_TARGETDIRTARGETDIR=""749

The last column in this row contains the installation sequence, which is sequenced to occur just before the WEBCA_TARGETVDIR action.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Adnovate
Netherlands Netherlands
Arnold Schrijver is an IT Architect for Adnovate (www.adnovate.com)

Comments and Discussions

 
QuestionHow to disable and enable the next button in the custom actions UI Form Using Orca Pin
SubrahmanyamGurram21-Jul-12 3:43
SubrahmanyamGurram21-Jul-12 3:43 
GeneralError 2810 resolved but Virtual Directory being created in IISROOT. Pin
Sudipta Chaudhari10-Apr-10 19:43
Sudipta Chaudhari10-Apr-10 19:43 
GeneralVS 2008 Pin
gotorg12-Feb-10 9:08
gotorg12-Feb-10 9:08 
GeneralRe: VS 2008 Pin
Sameer Nasrallah20-Feb-10 22:35
Sameer Nasrallah20-Feb-10 22:35 
GeneralRe: VS 2008 Pin
CarstenHTR22-Feb-10 2:39
CarstenHTR22-Feb-10 2:39 
GeneralRe: VS 2008 Pin
Member 182685319-Mar-10 19:01
Member 182685319-Mar-10 19:01 
GeneralRe: VS 2008 Pin
ggiminiani19-Dec-11 3:38
ggiminiani19-Dec-11 3:38 
GeneralBrilliant Article!! Pin
soven29-Jun-09 6:03
soven29-Jun-09 6:03 
Question64 Bit OS Problem Pin
Kannan B29-Jun-09 4:24
Kannan B29-Jun-09 4:24 
AnswerRe: 64 Bit OS Problem Pin
tedblock14-Jul-09 9:21
tedblock14-Jul-09 9:21 
QuestionError 1001. A configuration file cannot be created for the requested Configuration object Pin
pradeep kumarappagari10-Jun-09 3:11
pradeep kumarappagari10-Jun-09 3:11 
AnswerRe: Error 1001. A configuration file cannot be created for the requested Configuration object Pin
tinybag1619-Apr-10 17:25
tinybag1619-Apr-10 17:25 
GeneralRe: Error 1001. A configuration file cannot be created for the requested Configuration object Pin
pradeep kumarappagari3-May-10 1:15
pradeep kumarappagari3-May-10 1:15 
QuestionAdd Web Install Too Existing Install Project ?? Pin
Stephen Bovy6-May-09 12:32
Stephen Bovy6-May-09 12:32 
GeneralGetting An Error .... Pin
Kannan B16-Apr-09 22:46
Kannan B16-Apr-09 22:46 
GeneralOrca EXE Pin
Kannan B16-Apr-09 3:18
Kannan B16-Apr-09 3:18 
GeneralAdditional steps comment Pin
yasen kiprov7-Apr-09 3:37
yasen kiprov7-Apr-09 3:37 
QuestionDoesn't work with VisualStudio 2008's web project.. Pin
aurosea4-Mar-09 17:31
aurosea4-Mar-09 17:31 
GeneralVirtual Directory And Physical Path in Web setup Project Pin
shavil7-Jan-09 23:13
shavil7-Jan-09 23:13 
GeneralExcellent ! Pin
Rajganesh Mountbatton10-Dec-08 23:21
Rajganesh Mountbatton10-Dec-08 23:21 
GeneralBrilliant .. Pin
Balaji_Bala11-Sep-08 18:28
Balaji_Bala11-Sep-08 18:28 
QuestionVirtual directory pointing to physical path under "C:\inetpub\wwwroot" Pin
zhngmm18-Aug-08 9:35
zhngmm18-Aug-08 9:35 
QuestionTARGETDIR Pin
Mira Fahmy27-Jul-08 20:46
Mira Fahmy27-Jul-08 20:46 
Questionwhy didn't MSFT have this feature already Pin
liptonIcedTea21-Nov-07 12:04
liptonIcedTea21-Nov-07 12:04 
Generalhajaworld@yahoo.co.in Pin
haja me22-Sep-07 0:53
haja me22-Sep-07 0:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.