How to target 32bit and 64bit a .NET applications with WiX and separate MSI packages

Target 32bit and 64bit .NET applications

This post will explain how you can build msi packages using WiX for both 32bit and 64bit platforms.  The goal is to create 2 different msi packages. One for 64bit systems, which will install the program in to c:\Program Files on 64bit, and another msi package that will install the program in to c:\Program Files on 32 bit systems. The .NET application itself will be compiled with CPU target Any, which results in that it will run in 64bit mode on 64bit systems and 32bit mode on 32bit systems. Of course, you could also install the 32bit msi package on 64bit systems, which will end up being installed in c:\Program Files (x86).

Pre-requisites:

Microsoft Visual Studio 2008

In my environment, I used 64bit Windows7, so I installed the 64bit version of WiX build 3.0.5419.0-x64-setup

Create a simple .NET application

We will create a simple .NET Winforms application that will show some platform information, like this:

 

image

We will also create a WiX setup project and configure a new platform type in Visual Studio for the 64bit target.

Fire up Visual Studio and create a new Windows Forms project:

image

Add 3 labels to the form:

image

Add code in the Form Load event to fill the labels with info:

 

 

Create a Wix project

Add a new project to the solution, a WiX Setup project:

image

In the Product.wxs file, enter the following code:

 

And add references to WixUIExtension.dll and WixUtilExtension.dll.

What you will notice now is that you have 3 targets in your configuration:

image

The value you choose here will be transferred to the Platform variable in WiX. Unfortunately, the 64bit option is missing, so we must create that one.

Create a x64 configuration entry

Select the Configuration Manager.

image

Select  <New…>

image

image

Select the x64 option and click Ok.

Building

When you now build the Wix project, the output will be created in a new x64 folder. In the Product.wxs code, we also have a title that indicates that is runs in 64bit mode:

image

image

When installed, it will end up in c:\Program Files, just as we wanted.

The 32bit version of the msi is built when you select the x86 platform target

image

image

 

Hope this shed some light on how to deploy .NET applications for multiple targets.

Download the complete solution here.

3 thoughts on “How to target 32bit and 64bit a .NET applications with WiX and separate MSI packages

  1. Thanks for the great example. If this were more than a test project, you’d also want to have the package code differ between the 32-bit and 64-bit msi packages.

Leave a Reply

Your email address will not be published. Required fields are marked *