Click here to Skip to main content
13,344,765 members (59,796 online)
Click here to Skip to main content
Add your own
alternative version


71 bookmarked
Posted 21 Apr 2006

Specify a different location for Virtual Directories in Web Setup Projects

, 16 Oct 2006
Rate this:
Please Sign up or sign in to vote.
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.


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:


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:


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


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


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


About the Author

Arnold E. Schrijver
Architect Adnovate
Netherlands Netherlands
Arnold Schrijver is an IT Architect for Adnovate (

You may also be interested in...


Comments and Discussions

Questionhow to validate user input data in setup installer vs2005 Pin
ZahidMir3-Sep-07 5:24
memberZahidMir3-Sep-07 5:24 
AnswerRe: how to validate user input data in setup installer vs2005 Pin
yasen kiprov19-Mar-09 3:42
memberyasen kiprov19-Mar-09 3:42 
GeneralError message during setup Pin
steve_rm9-Aug-07 23:25
membersteve_rm9-Aug-07 23:25 
GeneralFile/Folder browse dialog Pin
Moin Ahmed16-Jul-07 3:20
memberMoin Ahmed16-Jul-07 3:20 
GeneralRe: File/Folder browse dialog Pin
Member 382767615-Feb-10 1:49
memberMember 382767615-Feb-10 1:49 
GeneralWonderful! Pin
Jinglecat23-Apr-07 7:33
memberJinglecat23-Apr-07 7:33 
GeneralProblem with TARGETDIR Pin
gmateos16-Apr-07 0:00
membergmateos16-Apr-07 0:00 
GeneralConcatenating the Physical Path with Virtual Directory Name Pin
raizu244-Dec-06 7:34
memberraizu244-Dec-06 7:34 

First off, thank you for writing this article. It has saved me valuable time as I had to write an install solution in tight deadlines.

Your solution works well in VS2005 although it would be very nice if the MSI transform could handle deleting records and modifying existing ones.

Anyways, here's the problem I need help in: I need to modify the [TARGETDIR] to be the directory name + the virtual directory name when the user hits 'Next'. How am I able to do this?

ie) if TARGETVDIR = test and TARGETDIR = d:\TEST_INSTALL then when the user hits next, the TARGETDIR = d:\TEST_INSTALL\test

Thanks in advance.
GeneralRe: Concatenating the Physical Path with Virtual Directory Name Pin
haja me22-Sep-07 1:48
memberhaja me22-Sep-07 1:48 
GeneralError when uninstalling application Pin
Sven Cipido1-Dec-06 5:35
memberSven Cipido1-Dec-06 5:35 
GeneralUnexpected error during installer execution Pin
usaeed@iael.com22-Nov-06 23:41
memberusaeed@iael.com22-Nov-06 23:41 
GeneralRe: Unexpected error during installer execution Pin
savi_hk6-Feb-07 2:34
membersavi_hk6-Feb-07 2:34 
GeneralRe: Unexpected error during installer execution Pin
kenny payne6-Nov-07 4:10
memberkenny payne6-Nov-07 4:10 
QuestionRemote Share Connect As properties? Pin
Ironhide15-Nov-06 6:22
memberIronhide15-Nov-06 6:22 
GeneralSlash added to end of path causes problems [modified] Pin
Ironhide15-Nov-06 6:07
memberIronhide15-Nov-06 6:07 
GeneralUrgent need help on getting path string. Pin
Ravi_Vaswani18-Oct-06 4:23
memberRavi_Vaswani18-Oct-06 4:23 
GeneralRe: Urgent need help on getting path string. Pin
Nomura_R9-May-11 1:28
memberNomura_R9-May-11 1:28 
GeneralHi can anybody pls help Pin
Ravi_Vaswani13-Oct-06 3:44
memberRavi_Vaswani13-Oct-06 3:44 
GeneralRe: Hi can anybody pls help [modified] Pin
Arnold E. Schrijver16-Oct-06 5:20
memberArnold E. Schrijver16-Oct-06 5:20 
GeneralRe: Hi can anybody pls help Pin
Ravi_Vaswani19-Oct-06 23:52
memberRavi_Vaswani19-Oct-06 23:52 
GeneralThis trick fails with 1.1 and Orca Pin
reunice28-Sep-06 4:25
memberreunice28-Sep-06 4:25 
Generalgood stuff Pin
ekynox17-Aug-06 21:54
memberekynox17-Aug-06 21:54 
QuestionMod on 1.1 setup not working, any suggestions? Pin
Andre Booysen7-Jun-06 1:11
memberAndre Booysen7-Jun-06 1:11 
QuestionAlternative? Pin
vivekthakur26-May-06 6:00
membervivekthakur26-May-06 6:00 
AnswerRe: Alternative? Pin
Jolanda3016-Jun-06 2:36
memberJolanda3016-Jun-06 2:36 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 16 Oct 2006
Article Copyright 2006 by Arnold E. Schrijver
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid