WiX Bootstrapper: How do I set burn variables from the command line?

17,580

First of all, the burn variables that you wish to set need to be set as Overridable. To do this you must include the follow namespace in your WXS: xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" and if you're using Visual Studio like me you need to include WixBalExtension.dll in your project references. Next you need to add the following attribute to all of the burn variables that you want to set via the command line: bal:Overridable="yes".

Now you can set the variables via the command line in this fashion:

BootstrapperSetup.exe /i /passive MyBurnVariable1=1 MyBurnVariable2=2


Below is an example of a WXS file that satifies all of the conditions described above:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
         xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">

  <Bundle Name="MyProduct" Version="1.0.0" Manufacturer="MyManufacturer" UpgradeCode="PUT-UPGRADE-CODE-HERE">

    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense">
      <bal:WixStandardBootstrapperApplication LicenseUrl="MyLicense.htm" ThemeFile="MyThemeFile.xml" LocalizationFile="MyLocFile.wxl" />
    </BootstrapperApplicationRef>

    <Variable Name="MyBurnVariable1" bal:Overridable="yes" Type="numeric" Value="0" />
    <Variable Name="MyBurnVariable2" bal:Overridable="yes" Type="numeric" Value="0" />

    <Chain>
      <MsiPackage Id="MyFirstMsiPackage"
                  SourceFile="first.msi"
                  InstallCondition="MyBurnVariable1 = 1" />

      <MsiPackage Id="MySecondMsiPackage"
                  SourceFile="second.msi">
        <MsiProperty Name="MY_PROPERTY" Value="[MyBurnVariable2]" />
      </MsiPackage>
    </Chain>
  </Bundle>
</Wix> 
Share:
17,580
bsara
Author by

bsara

Full stack developer with a passion for his family, open source, technology, problem solving, quality work, and helping people. My Online Profiles Dev.to NPM GitHub GitLab BitBucket JS Bin JS Fiddle XDA Developers

Updated on July 05, 2022

Comments

  • bsara
    bsara almost 2 years

    Using WiX 3.7 and .NET 4.0.

    How does one set burn variables when running a WiX bootstrapper EXE from the command line?

  • stukselbax
    stukselbax almost 9 years
    This is true for WixStdBA, but not for managed bootstrapper application. So it is strange that the logic for parsing and overriding variables from cmdline is not in the burn core.