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?
Asked
Active
Viewed 1.8k times
1 Answers
49
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)"

David Martin
- 11,764
- 1
- 61
- 74
-
Hi @David Martin, thanks, does this mean that I need to build two separate MSI's for x86 and x64? – sean717 Sep 05 '13 at 16:02
-
@sean717 Yes, although you could put them both into a bootstrapped exe. But that's a different question :-) – David Martin Sep 05 '13 at 17:25
-
@DavidMartin I'm trying to apply your solution, but I'm not sure where I should put the piece of code where you define the variables ot detect and set the architecture of the install. ¿In what file should I put that? – daniegarcia254 Aug 21 '15 at 10:47
-
@daniegarcia254 These are pre-processor variables so can be placed in any of your wix files, see here for more information http://wixtoolset.org/documentation/manual/v3/overview/preprocessor.html – David Martin Aug 21 '15 at 11:35
-
3This helped me -- I couldn't get the Wix installer project to build an x64 release no matter what I tried from the GUI. I opened the project file in Notepad and saw there were several duplicate entries. Once I deleted the duplicate entries for x64 and x86, I reopened project and was able to build a 64 bit installer – user1532208 Mar 25 '19 at 15:13