WiX .NET Bootstrapper - Feature Selection

2020-07-11 07:04发布

We are trying to get a custom .NET Bootstrapper to selectively install features in an MSI package through our WiX installer.

Having registered to the event PlanMsiFeature we thought that we would be able to access the features in our MSI and exclude certain features based upon preset conditions. The event, however, never appears to be invoked. Has anybody managed to use this event successfully?

Many thanks.

1条回答
Animai°情兽
2楼-- · 2020-07-11 07:14

We solved this issue. There were a couple of key items missing.

1) In the Bundle that contains our application, the MSI Package was required the following attribute.

EnableFeatureSelection="yes"

2) In the managed bootstrapper application we were setting the install condition (state) to Absent for the feature we don't wish to install. The missing piece here was that all the items we do wish to install need to have Local set for their state as Unknown causes all items to be installed.

void CustomBA_PlanMsiFeature(object sender, PlanMsiFeatureEventArgs e)
{
   if (e.FeatureId == "FEATURE_TO_EXCLUDE")
       e.State = m_installFeature ? FeatureState.Local : FeatureState.Absent;
   else
       e.State = FeatureState.Local;
}
查看更多
登录 后发表回答