Create MSI bootstrapper (setup.exe) using WiX Burn

In my previous blog post “Create a basic MSI installer using WiX Toolset”, I have shared about how I created a basic .msi installer using WiX toolset for my app deployment. And today, I’m going to share how I create a bootstrapper i.e. setup.exe using WiX to chain the installations that are packaged as *.msi. One of the reasons you need a bootstrapper is because there is only one instance of .msi can be run at a time. Using a bootstrapper, you can install the required prerequisites for your app deployment, e.g. .NET Framework.

Example of my bootstrapper UI Example of my bootstrapper UI

Example of project files structure for creating the bootstrapper

<root>
├── bootstrapper_res\
|   ├── banner.png
|   ├── ClassicTheme.wxl
|   └── ClassicTheme.xml
├── prereq\
|   └── NDP471-KB4033344-Web.exe
├── Bootstrapper.wxs
├── MakeBootstrapper.bat
├── myAppSetup.msi
├── ...

Folders:

  • bootstrapper_res - Contains graphic resource and theme files for my WiX bootstrapper UI
  • prereq - Contains necessary prerequisites to be bundled into my bootstrapper

WiX project files:

  • Bootstrapper.wxs - Main file for generating the bootstrapper (*.exe file)
  • MakeBootstrapper.bat - Batch script to compile Bootstrapper.wxs file
  • myAppSetup.msi - Example of .msi installer file for my app installation
  • banner.png, ClassicTheme.wxl & ClassicTheme.xml - Modified theme for customizing the bootstrapper interface (Check this GitHub repo for the source code)

Bootstrapper source code

Bootstrapper.wxs

<Wix
    xmlns="http://schemas.microsoft.com/wix/2006/wi"
    xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
    <Bundle Name="MiniAppKiller Bundle" 
        Version="!(bind.packageVersion.MainPackage)" 
        Manufacturer="Heiswayi Nrird" 
        UpgradeCode="56888B11-D5D0-4068-8E94-39E696DAD1D4" 
        Copyright="(C) 2018 Heiswayi Nrird" 
        IconSourceFile="images/app.ico" 
        AboutUrl="https://heiswayi.nrird.com"
        Compressed="yes">
        
        <!-- Layout setup -->
        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense">
            <bal:WixStandardBootstrapperApplication 
                LicenseUrl="https://heiswayi.nrird.com"
                LogoFile="bootstrapper_res/banner.png"
                ThemeFile="bootstrapper_res/ClassicTheme.xml"
                LocalizationFile="bootstrapper_res/ClassicTheme.wxl"
                LicenseFile="app\Eula-en.rtf"
                SuppressOptionsUI="yes" />
        </BootstrapperApplicationRef>

        <util:RegistrySearch Root="HKLM" 
            Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" 
            Value="Version" 
            Variable="Net4FullVersion" />
        <util:RegistrySearch Root="HKLM" 
            Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" 
            Value="Version" 
            Variable="Net4x64FullVersion" 
            Win64="yes" />
        
        <Chain DisableSystemRestore="yes">
            <ExePackage Id="Net471" 
                Name="Microsoft .NET Framework 4.7.1 Web Installer" 
                Cache="no" 
                Compressed="yes" 
                PerMachine="yes" 
                Permanent="yes" 
                Vital="yes"
                InstallCommand="/passive /norestart"
                SourceFile="prereq\NDP471-KB4033344-Web.exe"
                DetectCondition="(Net4FullVersion = &quot;4.7.2558&quot;) AND (NOT VersionNT64 OR (Net4x64FullVersion = &quot;4.7.2558&quot;))"
                InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Net4FullVersion = &quot;4.7.2558&quot; OR Net4x64FullVersion = &quot;4.7.2558&quot;))"/>
            <RollbackBoundary />
            <MsiPackage Id="MainPackage" 
                SourceFile="setup-1.0.msi" 
                DisplayInternalUI="yes" 
                Compressed="yes" 
                Vital="yes"/>
        </Chain>
    </Bundle>
</Wix>

For more detailed on other available element properties, please take a look on WiX Bundle Element documentation here.

Batch script for compiling the WiX project

These are the WiX toolset that I use in the script below:-

  • candle.exe - To generate *.wixobj file
  • light.exe - To compile *.wixobj and generate the bootstrapper file (*.exe).

MakeBootstrapper.bat

@echo off

"%WIX%bin\candle.exe" "Bootstrapper.wxs" -out "_Bootstrapper.wixobj" -ext WixNetFxExtension -ext WixBalExtension -ext WixUtilExtension -nologo
"%WIX%bin\light.exe" "_Bootstrapper.wixobj" -out "Bootstrapper.exe" -ext WixNetFxExtension -ext WixBalExtension -ext WixUtilExtension -nologo

More screenshots of my bootstrapper

Installing the packages Installing the packages

When user cancelled installation When user cancelled installtion

Extra good readings and references