Wix Burn EnableFeatureSelection

问题描述

我有一个Wix安装程序,可以通过自定义UI安装2个MSI。

我在2个MSI中拥有3个功能

MSI 1

  1. 功能A
  2. 功能B

MSI 2

  1. 功能C

用户可以选择安装A,B,AB,ABC或C。

要将功能设置为可选功能,我已经设置了EnableFeatureSelection =“ yes”并将PlanMsiFeature设置为Local / Absent(取决于用户是否要包含它们)。

这适用于MSI 1中的2个功能,但不适用于MSI 2中的功能

谢谢

绑定代码

    <Chain>
      <MsiPackage Id="1" Name="1.msi" SourceFile="1.msi" Vital="yes" Compressed="no" EnableFeatureSelection="yes"
                  displayName="1">
      </MsiPackage>
      
      <MsiPackage Id="2" Name="2.msi" SourceFile="2.msi" Vital="yes" Compressed="no"  EnableFeatureSelection="yes"
        displayName="2">
      </MsiPackage>
    </Chain>

BootstrapperApplication

PlanMsiFeature += SetupModel_PlanMsiFeature;

void SetupModel_PlanMsiFeature(object sender,PlanMsiFeatureEventArgs e)
{
    switch (e.FeatureId)
    {
        case "FeatureA":
            {
                e.State = IncludeA ? FeatureState.Local : FeatureState.Absent;
                return;
            }
        case "FeatureB":
            {
                e.State = IncludeB ? FeatureState.Local : FeatureState.Absent;
                return;
            }
        case "FeatureC":
            {
                e.State = IncludeC ? FeatureState.Local : FeatureState.Absent;
                return;
            }
    }

    e.State = FeatureState.Local;
}

解决方法

这需要反复试验。主要是错误。

Wix似乎在MSI中至少需要1个功能,因此我向两个MSI添加了一个空功能。

<Feature Id="blankFeature">
<Feature>