wixwindows-installerpropertiesinstallation-path

How do I set an MSI installation folder dynamically


I'm creating a web application installer using WiX. I want to allow the user to select the web site from a list of sites on the IIS server, and then install the app in a sub-directory of that web site's root folder.

I've finished the "select web site" portion. I have a custom action that sets a bunch of properties based on the selected site. One of those properties (WEB_SITE_ROOT_PHYSICAL_PATH) is the path to the web site's root folder.

However, I can't get the application to install to that path.

My directory structure is as follows:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="IIS_WEB_ROOT">
    <Directory Id="WEB_SITE_ROOT" Name=".">
      <Directory Id="INSTALLLOCATION" Name="$(var.ProductName)">

IIS_WEB_ROOT is defined as:

<Property Id="IIS_WEB_ROOT">
  <RegistrySearch Id="Search" Root="HKLM" Key="Software\Microsoft\InetStp" Name="PathWWWRoot" Type="raw" />
</Property>

WEB_SITE_ROOT_PHYSICAL_PATH is set to WEB_SITE_ROOT, as follows:

<Property Id="WEB_SITE_ROOT_PHYSICAL_PATH" Value="WEB_SITE_ROOT"/>

The web site selection dialog is displayed before the installation folder dialog. The installation folder dialog uses the following "standard property":

<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION"/>

The upshot of all this is that the application is installed into the IIS web root folder - not the web site root folder.

I'm just not sure how to get my installation folder to be set to my dynamically defined WEB_SITE_ROOT_PHYSICAL_PATH property. I need some pointers in the right direction. Do I need another custom action to set the installation folder after the WEB_SITE_ROOT_PHYSICAL_PATH property is set? If so, how do I set this to first after the web site selection dialog completes? Or, have I get all the pieces, but I just haven't wired them up correctly.


Solution

  • In order to set the property to the value of another property, you should author a custom action:

    <CustomAction Property="WEB_SITE_ROOT_PHYSICAL_PATH" Value="[WEB_SITE_ROOT]" />
    

    Of course, you should schedule this action after the original WEB_SITE_ROOT property is defined.

    Hope this helps.