20 May 2012

Create a single setup to target both 32-bit and 64-bit Windows

The following is a tutorial on how to create a bootstrapper project that can install either a 32-bit or 64-bit install package depending on the host operating system. Windows Installer will not allow a single msi package to be created that targets both 32-bit and 64-bit Windows but MSIStudio provides advanced bootstrapping functionality to make this possible. This tutorial will also create sample 32-bit and 64-bit install packages demonstrating MSIStudio support for both platforms.

This tutorial assumes we are developing the setup packages on 64-bit Windows. The 32-bit install package must be test installed on 32-bit Windows.

Create sample 32-bit and 64-bit setup projects

  • Run MSIStudio and select New Project from the File Menu and create a setup project called TestSetup64. This will create a 64-bit project with no files. Add a file to the install folder. Also add a registry key under HKEY_LOCAL_MACHINE\SOFTWARE called 'Sample Key'. Add a string value to this key called 'Sample Value' with string data of 'Sample Data'. Go into the settings for Default Release and change the Output Type to MSI File. Create a self contained msi file by enabling compression and embedding the CAB inside the msi file. Build the project to generate a 64-bit msi install package.

  • Create another setup project called TestSetup32. Display the 32-bit 'Program Files Folder' in the File System view. Add a sample file to this folder. Also add a registry entry exactly as descibed in the sample 64-bit project earlier. Go into the settings for Default Release and change the Output Type to MSI File. Create a self contained msi file by enabling compression and embedding the CAB inside the msi file. Also change the Target Platform to 'Intel 32-bit' in the Compatability section of the release settings. This ensures that the components are declared as 32-bit and registry data will get written to the redirected WOW6432node branch. Build the project to generate a 32-bit msi install package.

  • Optionally install and uninstall each package and verify that 32-bit files are installed to the Program Files (x86) folder and registry data is written to the WOW6432node branch. Also verify that the 64-bit package installs files into the Program Files folder and that registry data gets written to the main registry HKEY_LOCAL_MACHINE branch.

As described earlier, it is not possible to combine the two packages together to have a single msi package that can install on both 32-bit and 64-bit Windows. We now create an MSIStudio bootstrapper project to achieve this.

Create a bootstrapper project that contains both sample packages

  • Create a new bootstrapper project called TestSetup. Set the MSI File object source path to TestSetup64.msi and set the Condition field to 'VersionNT64'. Create another MSI File object setting the source path to TestSetup32.msi and the condition field to 'NOT VersionNT64'. Build the project generating the setup.exe file.

  • Run the setup.exe on 64-bit Windows and notice how the 64-bit files and registry entries get installed. Run the same setup.exe on 32-bit Windows and notice how the 32-bit package gets installed. The bootstrapper determines which package to install based on the conditions. As a further test, reverse the conditions on the MSI File objects and rebuild the setup project. Run the new setup.exe on both platforms again. Notice how the 32-bit msi package installs fine on 64-bit Windows, but that the 64-bit package cannot be installed on 32-bit Windows.

Bootstrapper projects can contain any number of msi packages. At install time, the user can choose which package to install from a list of available packages. The condition associated with each package is evaluated and if it doesn't evaluate to false then the package is displayed and made available for installation. This unique feature of bootstrapper projects allows software vendors to distribute all of their applications in a single distributable package simplifying the deployment process.