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?
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).
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
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 :)
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.