3

In my wix source code, I have to look for 2 entries in the registry to get an install directory :

<Property Id="INSTALLDIR_A"> 
 <RegistrySearch Id='RegA' Type='raw' 
   Root='HKLM' Key='Software\Path\To\A' Name='InstallLocation' /> 

 <Property Id="INSTALLDIR_B"> 
 <RegistrySearch Id='RegB' Type='raw' 
   Root='HKLM' Key='Software\Path\To\B' Name='InstallLocation' /> 

My install directory must be either INSTALLDIR_A or INSTALLDIR_B. If I had to look only to 1 entry, I would have implemented it like that :

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="INSTALLDIR" Name="My path">
    <!-- further code -->
  </Directory>
</Directory>

But I want INSTALLDIR to be either INSTALLDIR_A or INSTALLDIR_B depending on which one is defined. How to achieve this ?

Brainless
  • 1,522
  • 1
  • 16
  • 30
  • 2
    possible duplicate of [WIX: Set a property based on a condition](http://stackoverflow.com/questions/1690162/wix-set-a-property-based-on-a-condition) – Erti-Chris Eelmaa Jul 07 '14 at 11:16

1 Answers1

4

There's a custom action SetDirectory (http://wixtoolset.org/documentation/manual/v3/xsd/wix/setdirectory.html) for that. You might try something like using the first value as default and overwriting it if the other one is set:

<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="Software\Path\To\A" />
    </Directory>
  </Directory>

  <SetDirectory Id="INSTALLFOLDER" Value="[INSTALLDIR_B]">INSTALLDIR_B AND NOT INSTALLDIR_A</SetDirectory>
</Fragment>
mkko
  • 332
  • 2
  • 7