Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build WiX 3.6 project targeting x64?

Tags:

wix

My solution is built with platform setting "Any CPU". For my WiX 3.6 installer project settings, it seems that I can't set the target platform to "x64"; only "x86" is available. Can the WiX project be built targeting x64?

like image 517
sean717 Avatar asked Sep 05 '13 05:09

sean717


1 Answers

Windows installers cannot be built to target Any CPU, I typically build twice, with the managed code being set to Any CPU, whilst the installer has two configurations x86 and x64.

You may find you need to create the configurations, this can be done by right clicking on the solution and selecting configuration manager then selecting the drop down under platform. When you're complete you should be able to see the following defined in your wixproj:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <OutputPath>bin\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
    <DefineConstants>Debug</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <OutputPath>bin\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
    <DefineConstants>Debug</DefineConstants>
    <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
    <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
  </PropertyGroup>

To allow the installer to work with both x86 and x64 define variables to detect and set the architecture of the install.

<?if $(var.Platform) = x64 ?>
<?define bitness = "(64 bit)" ?>
<?define Win64 = "yes" ?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
<?define bitness = "(32 bit)" ?>
<?define Win64 = "no" ?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>

I append the bitness variable to the name as a visual clue:

<Product Name="My Install $(var.bitness)"

Refer to the Program Files Folder as appropriate:

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="$(var.PlatformProgramFilesFolder)">

Components have the Win64 flag set appropriately:

<Component Win64="$(var.Win64)"
like image 75
David Martin Avatar answered Nov 08 '22 20:11

David Martin