I have a web setup project which by default shows the virtual directory in the textbox installer screen. I wish that the virtual directory name cannot be edited by the user and always defaults to the one I have setup in my msi. How can this be achieved?
-
Also if this cannot be achieved then how can I get the value of the changed virtual directory using the Context.Parameters[] ? – chugh97 Apr 03 '09 at 15:01
8 Answers
If you don't want the user to change the virtual directory you can simply remove the "Installation Address" dialog from the User Interface.
- Right Click installer project and select "User Interface".
- Expand the "Start" node.
- Right click on "Installation Address".
- Select "Delete"
If you want different parameters for the Web site, virtual directory, application pool that is normally selected by the installation address dialog you can override with a custom action as others have described.
However, in my experience custom actions do not help with setting defaults that the user can change because they execute After the dialogs that ask for user input.
The easiest way to set some defaults that the user can override if necessary in a dialog is to do the following.
- Remove the Welcome Page.
- Add a Textboxes dialog (for example "Textboxes (A)")
- Change Visible properties for all the textboxes to false so no textboxes are shown.
- Change the BannerBitmap and BodyText property so it looks somewhat like a welcome page.
- Set the necessary properties you want to override in the "Edit***<n>Property" and set the default value in the "Edit<n>***Value".
The most useful properties (IMHO) are.
TARGETDIR - Where the files are to be copied.
TARGETVDIR - The Virtual Directory to be created in the specified site.
TARGETAPPPOOL - The application pool to use (NOTE: This must exist, it won't be created)
TARGETSITE - The website where the virtual directory is to be created (NOTE: This is the metabase value for the web site... For example: "/LM/W3svc/2". Also note that the site must exist).
There is a full list of properties for the installer can be found here.
If you really want better control over the IIS setup I would suggest changing your project to a standard Windows Installer project and creating custom Install actions so that you can programatically create AppPools. A good place to start to understand programmaticly creating these things is here.
The biggest reason for doing it this way is that custom actions run after prompting but the app pool and web sites must be created before the installer can prompt.

- 3,998
- 6
- 26
- 28
-
1That note about TARGETSITE being a metabase value was a lifesaver - thank you! – ladenedge Apr 30 '10 at 04:59
-
-
to my knowledge you are the only person on the internet to document that TARGETAPPPOOL maps to the app pool.. TY – Dead.Rabit Oct 03 '13 at 12:44
-
@RonnBlack can you please tell me how to get the actual site name from TARGETSITE instead of metabase value or is it possible to get the site name from metabase value? – Rezoan Mar 12 '14 at 14:16
-
@Rezoan its been a very long time since I looked at this but I seem to remember being frustrated with not being able to use the name of the site for anything. The installer only understood the metabase value and I had to dig around to find that. I do see another post where someone supplied a powershell script that supposedly can get the metabase value from site name. http://stackoverflow.com/a/7098921 – RonnBlack Mar 13 '14 at 07:00
Sounds good in theory but near as I can tell, doesn't work, at least not for setting AppPool. I have a custom action to set the apppool (which by the way works fine when the installer is built with VS2005) in my vs2008 web setup project.
DirectoryEntry IISVdir = new DirectoryEntry(String.Format("IIS://{0}{1}/{2}", strServer, strRootSubPath, Vdir));
IISVdir.Properties["AppPoolId"].Value = appPool;
IISVdir.CommitChanges();
The installer runs with no dialog (removed the installation address UI node) but the AppPool set on the virtual directory ends up being DefaultAppPool.
Other custom actions in my helper class do run and work.
So there must be some other magic incantations needed.
Thanks.
-
this seems to work from the command line: XYZZX.msi /qr /TARGETAPPPOOL="MyAppPoolName" Is it possible to set the TARGETAPPPOOL parameter in a custom action? – May 06 '09 at 21:27
-
Okay, since the command line option worked, maybe this would: if (this.Context.Parameters.ContainsKey("TARGETAPPPOOL")) this.Context.Parameters["TARGETAPPPOOL"] = appPool; else { this.Context.Parameters.Add("TARGETAPPPOOL", appPool); } Nope - still set to DefaultAppPool – May 06 '09 at 22:07
-
1I just had a similar problem. I could only solve it by getting by custom action to run at the Commit stage, instead of the Install stage. – Tim C Jan 27 '10 at 11:29
-
Like Tim C I was also only able to get the AppPool to change at the Commit stage. Within the Commit override, the appPool must be set before the call to base.Commit(savedState). – Slider345 Jul 22 '11 at 16:21
In order to get the Virtual Directory using Context.Parameters
- Add a Custom Action to Install node (use this url if you want to know how to add custom actions)
- Right Click on the custom action and select properties window.
- For CustomActionsData property set /targetvdir="[TARGETVDIR]".
- Now in your installer class you can get the virtual dir name by Context.Parameters["targetvdir"]. Hope this helped you :)

- 176
- 1
- 6
Lo-tech solution: edit the vdproj file in notepad++ to set the virtual directory and remove the Installation Address dialog from the User Interface Editor.

- 510
- 7
- 17
-
I wonder why no one else answered this. Simple and easy. Thanks a ton. – Shakti Prakash Singh Mar 03 '15 at 08:37
For me in VS
Right click on setup project
View -> File System
Web Application Folder (in the left pane)
in the property window (to the right, bottom)
Virtual Directory (the last one)
Here you can change/set the default path on IIS i.e. target directory which can be installed.
Switch to Wix and use their Web Extensions

- 24,862
- 16
- 85
- 145

- 31,691
- 7
- 68
- 87
-
I am looking at the websetup project as I am not interested in open source as org does not allow it. – chugh97 Apr 09 '09 at 09:07
-
1Wix is written & maintain by Microsoft, it was suppose to be part of Visual Studio 10. Many originations (Incl. the Office 2007 setup) are using Wix without any problem. – Shay Erlichmen Apr 11 '09 at 17:30
Select your setup project, View > Editors > User Interface, select the Installation Address dialogs, and delete them.
EDIT:
As Shay points out, users can override the default install location from the command line. To override this, you should set the TARGETDIR property in your InstallExecuteSequence. Unfortunately, you cannot change this sequence from Visual Studio, you have to use Orca:
- Build your Setup project.
- Open the MSI file from Orca.
- Create a new custom action of Type 51 (set property) with Source "TARGETDIR" (without quotes), Target of your destination folder, and a unique name for Action (the convention is to use a GUID with initial underscore).
- Create a new row in the InstallExecuteSequence with your unique name for Action, "NOT Installed" for Condition, and a sequence number before the use of TARGETDIR (750 was the first use in the sample I made, so I used a sequence of 555).

- 21,513
- 29
- 75
- 90
-
deleting from the UI would still allow the user to change the setup dir via command line. – Shay Erlichmen Apr 11 '09 at 17:33
Org does not allow open source, or GPL open source.
Solutions: * edit the custom action (right click>view>custom action) to fix the virtual directory and path Change the customactiondata:
/targetdir="[TARGETDIR]\" /connectionstring="[CONNECTIONSTRING]" /targetvdir="[TARGETVDIR]" /targetsite="[TARGETSITE]"
To:
/targetdir="[TARGETDIR]\" /connectionstring="[CONNECTIONSTRING]" /targetvdir="FIXED_NAME" /targetsite="[TARGETSITE]"
You might just delete the Installation Address from user interface, and setup a component that passes information to the custom install
- Write a wrapper over msbuild with msbuildtasks

- 4,625
- 2
- 21
- 15