views:

639

answers:

3

I have a fairly complicated installer that I'm writing in Wix that has a lot of custom dialog options based on which components you're installing. Generally, defaults are fine, and thus an unattended install would succeed, but having this customization helps things.

What I'm wondering is, what are best practices in Wix for doing UI conditionals? I've noticed that Wix evaluates all <Publish> tags, regardless of whether or not the last one evaluated to true, which is leading to a lot of code like this:

<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component1Questions" Order="1">INSTALLCOMPONENT1</Publish>
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component2Questions" Order="2">NOT INSTALLCOMPONENT1 AND INSTALLCOMPONENT2</Publish>
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component3Questions" Order="3">NOT INSTALLCOMPONENT1  AND NOT INSTALLCOMPONENT2 AND INSTALLCOMPONENT3</Publish>
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">NOT INSTALLCOMPONENT1  AND NOT INSTALLCOMPONENT2 AND NOT INSTALLCOMPONENT3</Publish>

And similarly on the "back' sections for each dialog. Is this best practice for this? Is there a way to short circuit evaluation of Publish elements and take the first one that returns true?

+2  A: 

You're already using the Publish/@Order element to simplify the code, however I would advise being as explicit as possible.

You can simplify the logic anyway and not worry about the Order value...

<Publish ... Value="Component1Questions">CMP1 And Not (CMP2 Or CMP3)</Publish>
<Publish ... Value="Component2Questions">CMP2 And Not (CMP1 Or CMP3)</Publish>
<Publish ... Value="Component3Questions">CMP3 And Not (CMP1 Or CMP2)</Publish>
<Publish ... Value="VerifyReadyDlg">Not (CMP1 Or CMP2 Or CMP3)</Publish>
sascha
Logic is simpler but slightly incorrect. If I want to install all 3 components, the next button wouldn't work in this case.
Jeff
Ah, so they're not mutually exclusive. That makes more sense then ;)
sascha
A: 

I still don't know if it is a good practice or not, but I get the same results with something like this:

<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component1Questions" Order="4">INSTALLCOMPONENT1</Publish>
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component2Questions"  Order="3">INSTALLCOMPONENT2</Publish>
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component3Questions" Order="2">INSTALLCOMPONENT3</Publish>
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="1">1</Publish>

I mean, reverse the order numbers and forget about compositing the conditions. At the end, the number of conditions you have it's the same but it's much more maintainable and readable. Of course, this means that more than one "NewDialog" event is raised but only the last one is shown. Does anybody know any good reason for not doing so?

waj
A: 

"Does anybody know any good reason for not doing so?"

Yes. It's not allowed.

See the this blog http://legalizeadulthood.wordpress.com/2009/10/22/branching-wizard-sequences-with-wix/

SWPalmer