Virtual Directory in Web Setup Project

江枫思渺然 提交于 2019-11-29 06:20:43

问题


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?


回答1:


If you don't want the user to change the virtual directory you can simply remove the "Installation Address" dialog from the User Interface.

  1. Right Click installer project and select "User Interface".
  2. Expand the "Start" node.
  3. Right click on "Installation Address".
  4. 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.

  1. Remove the Welcome Page.
  2. Add a Textboxes dialog (for example "Textboxes (A)")
  3. Change Visible properties for all the textboxes to false so no textboxes are shown.
  4. Change the BannerBitmap and BodyText property so it looks somewhat like a welcome page.
  5. 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.




回答2:


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.




回答3:


In order to get the Virtual Directory using Context.Parameters

  1. Add a Custom Action to Install node (use this url if you want to know how to add custom actions)
  2. Right Click on the custom action and select properties window.
  3. For CustomActionsData property set /targetvdir="[TARGETVDIR]".
  4. Now in your installer class you can get the virtual dir name by Context.Parameters["targetvdir"]. Hope this helped you :)



回答4:


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



回答5:


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:

  1. Build your Setup project.
  2. Open the MSI file from Orca.
  3. 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).
  4. 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).



回答6:


Switch to Wix and use their Web Extensions




回答7:


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.




回答8:


For me in VS

  1. Right click on setup project

  2. View -> File System

  3. Web Application Folder (in the left pane)

  4. in the property window (to the right, bottom)

  5. Virtual Directory (the last one)

    Here you can change/set the default path on IIS i.e. target directory which can be installed.



来源:https://stackoverflow.com/questions/714309/virtual-directory-in-web-setup-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!