Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditionally set single WiX Property to different values

I have an installer that deploys a website as either a SSL or non-SSL IIS site depending on whether a property is set or not. I've been asked to add the option to set the port, which isn't a problem, but I'd like to set the port to the default values (80 or 443) if the value isn't set.

I tried something like:

    <SetProperty Id="OUTPORT" Before="InstallFiles" Value="80"><![CDATA[SSL=0]]></SetProperty>
    <SetProperty Id="OUTPORT"  Before="InstallFiles" Value="443"><![CDATA[SSL=1]]></SetProperty>

But, obviously, WiX complains about the custom action having the duplicate ID SetOUTPORT.

Am I jumping down another WiX-shaped rabbit hole here?

like image 903
Damien Ryan Avatar asked Jul 08 '11 16:07

Damien Ryan


2 Answers

The accepted answer is not correct in needing to convert to writing out in full the custom action and sequencing (no longer?).

As per documentation for WiX 3, SetProperty Element

Without setting SetProperty\@Action

<SetProperty Id="OUTPORT" Before="InstallFiles" Value="80"><![CDATA[SSL=0]]></SetProperty>
<SetProperty Id="OUTPORT"  Before="InstallFiles" Value="443"><![CDATA[SSL=1]]></SetProperty>

Duplicate symbol 'CustomAction:SetInstallFiles' found

Action. String. By default, the action is "Set" + Id attribute's value. This optional attribute can override the action name in the case where multiple SetProperty elements target the same Id (probably with mutually exclusive conditions).

The following works without having to change to writing out custom actions.

<SetProperty Action="SetInstallFiles0" Id="OUTPORT" Before="InstallFiles" Value="80"><![CDATA[SSL=0]]></SetProperty>
<SetProperty Action="SetInstallFiles1" Id="OUTPORT" Before="InstallFiles" Value="443"><![CDATA[SSL=1]]></SetProperty>

It works in WiX 3.7, and I am not sure about which first version it is available from.

like image 62
Greg Domjan Avatar answered Nov 08 '22 01:11

Greg Domjan


SetProperty now supports the Action attribute to let you specify custom action ids when you want to have multiple SetProperty elements for the same property with different conditions.

like image 29
Bob Arnson Avatar answered Nov 08 '22 02:11

Bob Arnson