开发者

Conditionally set single WiX Property to different values

开发者 https://www.devze.com 2023-03-18 02:51 出处:网络
I have an installer that deploys a website as ei开发者_C百科ther 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\

I have an installer that deploys a website as ei开发者_C百科ther 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消