0
votes

I am trying to create one installer (one MSI file) for both x86 and x64. I would like the installation process to install only relevant files based on the target machine platform. Till now I had one only MSI for x86 and it worked as expected. Now I added this section:

   <!-- Details to support both x86 and x64 platforms-->
  <?if $(var.Platform) = x64 ?>
  <?define ProductName = "MyApp (64 bit)" ?>
  <?define Win64 = "yes" ?>
  <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
  <?define ExportReleaseComponentGroup  = "Export64ReleaseComponentGroup" ?>
  <?define MyApplication  = "$(var.x64SourcePath)\MyApp.exe" ?>
  <?else ?>
  <?define ProductName = "MyApp" ?>
  <?define Win64 = "no" ?>
  <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
  <?define ExportReleaseComponentGroup  = "Export32ReleaseComponentGroup" ?>
  <?define MyApplication  = "$(var.win32SourcePath)\MyApp.exe" ?>
  <?endif ?>

Now I get some errors:

  1. In a x64 machine it is installed under Program Files (x86) folder. I am compiling the SetupProject in x86, can it be the reason for that? relevant code:

    <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="$(var.PlatformProgramFilesFolder)">
    
  2. The application does not run when installation ends. relevant code:

    <!--CA to launch the exe after install-->
    <Property Id="WixShellExecTarget" Value="$(var.MyApplication)" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
    
  3. A desktop shortcut and a start menu shortcut is not created. relevant code:

    <Component Id="ProgramFilesShortcut" Guid="{My-Guid}">
        <Condition>MY_DESKTOP_SHORTCUT</Condition>
        <Shortcut Id="desktopMyApp" Directory="DesktopFolder" Name="MyApp" Target="$(var.MyApplication)" WorkingDirectory="bin" Icon="MyIcon.ico">
        </Shortcut>
        <RemoveFolder Id="ProgramFilesShortcut" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
    </Component>
    
    <Component Id="ProgramMenuDir" Guid="{My-Guid}">
        <Shortcut Id="startmenuMyApp" Directory="ProgramMenuFolder" Name="MyApp" Target="$(var.MyApplication)" Icon="MyIcon.ico" WorkingDirectory="bin" Arguments="-s">
    <!-- Set the AppID in order to get toasts to work -->
        <ShortcutProperty Key="System.AppUserModel.ID" Value="MyCompany.MyApp" />
        </Shortcut>
        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
    </Component>
    

Any idea what am I doing wrong?

1

1 Answers

1
votes

You are using compile-time variables so you are producing an MSI for either a 32-bit or a 64-bit installations. An MSI package must target either one or the other. In some cases, it doesn't matter but the design is to get components that do matter in the right place.

It could be possible to share the source between separate 32-bit and 64-bit builds.

Once you have the two MSI, you can use a WiX Bootstrapper project to bundle them and install the appropriate one on the target system.