This article explains how you can bundle two MSI packages, one for each platform (Win32 and x64 versions of Windows), into a single bootstrapped installer. The bootstrapper will check the target operating system and unpack and execute the proper package for the version that was detected.
How to build a single installer for both platforms
- First, download the zip file that is linked at the bottom of this article. Decompress it, and copy the contents into the Bootstrap\Templates sub folder of your MSI Factory program folder.
- Now, build your first MSI package. In this walk through, I assume that you will have two projects, one for each platform, and that you are going to build the exe together with the 32 bit version of your MSI. So, build your 64 bit installer first. Of course, the platform for the MSI is set in the project settings, on the Package tab.
- Build the second MSI package, for the 32 bit platform, in the same manner. You will need to give a different name to the resulting MSI package, or place the file into a different folder. In this sample, I assume that the 64 bit MSI package is named setup-x64.msi while the 32 bit version is simply setup.msi, both packages deployed in the same folder.
- After both packages were built successfully (and hopefully working as expected), you can now bundle them together in a single installer. Go to Tools > Bootstrapper Designer, and start a new project. If you installed the template files from my zip file below correctly, you now should have a new option, like shown below:
- Once the new bootstrapper project was created from the template, go to the Files tab. Now it is time to include both MSI packages. Make sure that you assign the ID "Win32setup" to the 32 bit package, and "x64setup" to the 64 bit package. The names of the MSI packages themselves do not matter at all, but the IDs must match or the installer script will fail. This is also mentioned in the "TODO" comment of the mainscript.lua itself.
- After you made these edits, make sure you saved your bootstrapper project.
- Now back to the Build Settings in the MSI Factory interface. Select the Custom bootstrapper option, and browse to the folder where you saved the bootstrapper's XML file. In the field Additional command line options, you probably want to provide the product name, version number etc, like suggested in the screen.
- Finally, build the project. The MSI package will be built, and the bootstrapper will be assembled. If you inspect the build log window, you should see that two MSI packages were actually added to the executable:
Your bootstrapped installer (setup.exe) should now work perfectly for both supported platforms. The "magic" happens in the mainscript.lua file, where you call the proper MSI for the platform:
if (g_IsProductInstalled(strProductCode)) then -- Extract the MSI (if needed) and get the proper command line to pass. strCommandLine = g_GetInstalledRunCommandLine(strProductCode, strPackageCode, strProductVersion, strInstallerPathExtracted, true, ""); else -- Extract the correct MSI from the archive, according to the platform if System.Is64BitOS() then g_ExtractNamedMSIFromArchive("x64setup", strInstallerPathExtracted); else g_ExtractNamedMSIFromArchive("Win32setup", strInstallerPathExtracted); end strCommandLine = "-i \""..strInstallerPathExtracted.."\""; end
The function g_ExtractNamedMSIFromArchive() is really just a minor adaptation of the g_ExtractMSIFromArchive() that is defined in _global_functions.lua. With this sample, you should be able to understand how you can modify the bootstrapper even further, should you need so.
If you found this example helpful, please leave a comment below.
Don't have MSI Factory?
If you want to purchase a license for MSI Factory 2, now is a good time! For a limited period, you can get 10% off the list price simply by clicking the banner below: