19

Using WiX 3.7 and .NET 4.0.

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

bsara
  • 7,940
  • 3
  • 29
  • 47

1 Answers1

41

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> 
bsara
  • 7,940
  • 3
  • 29
  • 47
  • 2
    This is true for [WixStdBA](https://github.com/wixtoolset/wix3/blob/4786b1306b614b83cb96ad1b07f7597992f37126/src/ext/BalExtension/wixstdba/WixStandardBootstrapperApplication.cpp), 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. – stukselbax May 26 '15 at 10:14