2
votes

I'm a newbie to Wix burn. I'm making a wix Bootstrapper Application (BA) with multiple msi to install and an UI consisting of one panel with checkboxes and a button install. Each checkbox invites the user to select/unselect a msi, then the user presses "Install" and my BA should install the checked msi.

In my Chain element in the main .wxs file, I plan to use MsiPackage elements with a condition attribute to determine whether yes or no the user has selected it.

Now my question is : how to interface these condition attributes with the checkboxes ? Or in other words: how to get the checkbox information into the Wix .wxs file ?

1

1 Answers

2
votes

I can explain how I do it. May there's a better way. My checkBoxes are bound to properties in a ViewModel class. When a checkBox value is changed in the setter of the property I set the value of a variable defined in the Bundle.wxs file.

private bool _installApp1Checked;
public bool InstallApp1Checked
{
    get { return _installApp1Checked; }
    set
    {
    _installApp1Checked = value;
        if (value == true)
        {
            Bootstrapper.Engine.StringVariables["InstallApp1"] = "1";
        }
        else
        {
            Bootstrapper.Engine.StringVariables["InstallApp1"] = string.Empty;
        }
        RaisePropertyChanged("InstallApp1Checked");
    }
}

private bool _installApp2Checked;
public bool InstallApp2Checked
{
    get { return InstallApp2Checked; }
    set
    {
    _installApp2Checked = value;
        if (value == true)
        {
            Bootstrapper.Engine.StringVariables["InstallApp2"] = "1";
        }
        else
        {
            Bootstrapper.Engine.StringVariables["InstallApp2"] = string.Empty;
        }
        RaisePropertyChanged("InstallApp2Checked");
    }
}

private bool _installApp3Checked;
public bool InstallApp3Checked
{
    get { return _installApp3Checked; }
    set
    {
    _installApp3Checked = value;
        if (value == true)
        {
            Bootstrapper.Engine.StringVariables["InstallApp3"] = "1";
        }
        else
        {
            Bootstrapper.Engine.StringVariables["InstallApp3"] = string.Empty;
        }
        RaisePropertyChanged("InstallApp3Checked");
    }
}

And in the Bundle.wxs I have:

<Wix ...>
    <Bundle ...>
...
    <Chain>
        ...
      <MsiPackage>
        ...
        <MsiProperty Name="InstallApp1" Value="[InstallApp1]"/>
        <MsiProperty Name="InstallApp2" Value="[InstallApp2]"/>
        <MsiProperty Name="InstallApp3" Value="[InstallApp3]"/>
        ...
      </MsiPackage>
        </Chain>
    </Bundle>
</Wix>

By using the tag the properties of the ViewModel class are available in the wsx file. Then these values are available at the moment of the installation in my product.wxs:

<Product >
...

    <Property Id="InstallApp1">
    </Property>
    <Property Id="InstallApp2">
    </Property>
    <Property Id="InstallApp3">
    </Property>
    <Feature Id="ProductFeature" Title="Alvenos" Level="0">
      <ComponentRef Id="ProductComponents" />
      <Condition Level="1">InstallApp1</Condition>
    </Feature>
    <Feature Id="AlvenosVSIXFeature" Title="Alvenos" Level="0">
      <ComponentRef Id="AlvenosVsix" />
      <Condition Level="1">InstallApp2</Condition>
    </Feature>
    <Feature Id="AlvenosServerVSIXFeature" Title="Alvenos" Level="0">
      <ComponentRef Id="AlvenosServerVsix" />
      <Condition Level="1">InstallApp3</Condition>
    </Feature>

...
</Product>

You can see the the default value of the Level attribute of the Feature tag is set to 0. That means that the app will not be istalled. But if in the Condition tag InstallApp[1],[2] or [3] is set 1 the Level is set to 1 and the app is installed. Use ComponentRef to refernce a Component tag that will contain information about the destination folder of the app that you will install.

   <Fragment>
    <ComponentGroup Id="InstallApp1" Directory="[target directory id]>
      <Component Id="ProductComponent">
        <File Source="[your app part of the installer]" />
      </Component>
      ...
  </Fragment>

I hope you get the idea.