Jiang
Jiang

Reputation: 33

Installation of mutually exclusive features in WiX

There are two features on Custom Setup, if user chose one feature, another feature will be disabled automatically, it means these two features is mutually exclusive.

How could I achieve?

Thanks for your help

Upvotes: 1

Views: 1212

Answers (2)

encrypted name
encrypted name

Reputation: 269

These two should be selected in such a way, as below 3 scenarios.

if A is selected, B should be deselected

if B is selected, A should be deselected

user can unselect both the features.

I am able to do 1 and 2 by using below approach.

Created a clone of CustomSetup and named it as CustomSetup1.

And in the Tree control behavior, I added below events.

Remove:

Condition:MsiSelectionTreeSelectedFeature="A" and MsiSelectionTreeSelectedAction="3"

Feature Name: B

Remove:

Condition:MsiSelectionTreeSelectedFeature="B" and MsiSelectionTreeSelectedAction="3"

Feature Name: A

New Dialog:

Condition: MsiSelectionTreeSelectedFeature="A" and MsiSelectionTreeSelectedAction="3"

Dialog Name: CustomSetup1

Similarly, one more with condition:MsiSelectionTreeSelectedFeature="B" and MsiSelectionTreeSelectedAction="3"

And in the Behavior os CustomSetup1, I replaced new dialog with CustomSetup.

This works for 1 and 2 scenarios, like

if I select A, B gets disabled.

If I select B,A gets disabled.

But If I unselect A or B, they themselves not getting disabled.

I mean , 3rd scenario not working.I am not able to unselect any of these features.

Upvotes: 0

Christopher Painter
Christopher Painter

Reputation: 55571

There's nothing in MSI that will do this natively as MSI doesn't have the concept of mutually exclusive features. It can be done using a series of custom actions and control events but it's tricky because of another windows installer feature that the feature state changes won't evaluate until you transition to another dialog.

If possible, consider using a radiobox to abstract the choice and then drive the feature installation states. Otherwise also consider if you can safely install both features but then choose which implementation to use at runtime in your application. This would make your installer development a lot easier and give you greater control in a language you are more familiar with.

Upvotes: 2

Related Questions