WiX Bootstrapper: How do I set burn variables from

2019-02-03 07:10发布

问题:

Using WiX 3.7 and .NET 4.0.

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

回答1:

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>