Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WIX Installer - Differentiate 32bit from 64bits

Tags:

wix

I am new to wix and I have a quick fix to do ...

Here is my issue, I have an installer which install and register some dll but we do not want to install the second dll on 64bits architecture.

Here is the schema of our curent installer file : ... ...

I tried to add a condition, like this

<Directory Id="INSTALLDIR" .....>
   <Component Id="IDDLL" Guid="20E4601C-D93C-4A86-A0D9-31145D5443E6">
       <File Id="common.dll" Name="common.DLL" ....  SelfRegCost="1"/>
       <File Id="for32bits.dll" Name="for32bits.DLL" ....  SelfRegCost="1"/>
       <Condition> %PROCESSOR_ARCHITECTURE="x86" </Condition>
   </Component>

   <Component Id="IDDLL" Guid="20E4601C-D93C-4A86-A0D9-31145D5443E6">
       <File Id="common.dll" Name="common.DLL" ....  SelfRegCost="1"/>
       <Condition> %PROCESSOR_ARCHITECTURE~="x86" </Condition>
   </Component>
</Directory>

This does not work (duplicate symbols errors)

I also tried with a if statement but it looks to be processed at compilation time, so it did not worked either :

<Directory Id="INSTALLDIR" .....>
   <Component Id="IDDLL" Guid="20E4601C-D93C-4A86-A0D9-31145D5443E6">
       <File Id="common.dll" Name="common.DLL" ....  SelfRegCost="1"/>
       <? if %PROCESSOR_ARCHITECTURE = "x86" ?> 
             <File Id="for32bits.dll" Name="for32bits.DLL" ....  SelfRegCost="1"/>
       <?endif?> 
   </Component>
</Directory>

Can someone give me a clue on how to do this please ?

like image 597
Traktopel Avatar asked Jan 13 '12 16:01

Traktopel


2 Answers

My experience is that %PROCESSOR_ARCHITECTURE is unreliable. I use VersionNT64 to consistently handle 32-bit vs 64-bit.

The following example installs a registry key selectively based on the local architecture:

<Component Id="RegistryAppPathsFoxit64" Guid="{FD5740AC-FE2C-4043-926B-DCE7422D77AE}">
  <Condition>VersionNT64</Condition>
  <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\FoxitReader.exe" Action="createAndRemoveOnUninstall">
    <RegistryValue Type="string" Value="C:\Program Files (x86)\Foxit Software\Foxit Reader\Foxit Reader.exe" />
  </RegistryKey>
</Component>

<Component Id="RegistryAppPathsFoxit32" Guid="{7E78E125-CF56-46FC-BAF5-00B748052153}">
  <Condition>NOT VersionNT64</Condition>
  <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\FoxitReader.exe" Action="createAndRemoveOnUninstall">
    <RegistryValue Type="string" Value="C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe" />
  </RegistryKey>
</Component>
like image 102
Chris Schiffhauer Avatar answered Oct 17 '22 19:10

Chris Schiffhauer


Treat each architecture in its own component, each with a unique GUID:

<Directory Id="INSTALLDIR" .....>
   <Component Id="IDDLL32" Guid="20E4601C-D93C-4A86-A0D9-31145D5443E6">
       <File Id="for32bits.dll" Name="for32bits.DLL" ....  SelfRegCost="1"/>
       <Condition> %PROCESSOR_ARCHITECTURE="x86" </Condition>
   </Component>

   <Component Id="IDDLL64" Guid="20E4601C-D93C-4A64-A0D9-31145D5443E6">
       <File Id="common.dll" Name="common.DLL" ....  SelfRegCost="1"/>
       <Condition> %PROCESSOR_ARCHITECTURE~="x86" </Condition>
   </Component>
</Directory>
like image 41
KMoraz Avatar answered Oct 17 '22 19:10

KMoraz