在对话框级别的 WIX 片段中有条件地定义 属性

Conditionally define Property in WIX Fragment on dialog level

在这里您可以看到对话框中的控件,它有条件地发布属性。但是在显示对话框时需要可以访问这些属性,因为其他控件(例如文本框)会使用它们。

如何在不弄乱之前对话框的按钮的情况下实现这一点?

    <UI Id="IdOfUI">
        <Dialog Id="IdOfDialog">
            <Control Id="IdOfControl" Type="PushButton" >
              <Publish Property="PROP" Value="1" Order="1"><![CDATA[PROP2 <> ""]]></Publish>
              <Publish Property="PROP" Value="2" Order="1"><![CDATA[PROP2 = ""]]></Publish>
              <Publish Property="PROP" Value="3" Order="1"><![CDATA[PROP2 = "" AND PROP3 = ""]]></Publish>
              ...
            </Control>
        </Dialog>
    <UI>

最后我用内置 SetProperty CustomAction 解决了它,它修改了 InstallExecuteSequenceInstallUISequence 在幕后。

The tool Orca was veeery helpful - it shows the resulting sequences in msi

<Fragment>
    <Property Id="PROP1" />
    <Property Id="PROP2" />

    <SetProperty Id="PROP1" Action="SetPROP1_0" After='AppSearch' Value="VALUE1" ><![CDATA[PROP1 <> ""]]></SetProperty>
    <SetProperty Id="PROP1" Action="SetPROP1_1" After='AppSearch' Value="[VALUE2]"><![CDATA[PROP1 = "" AND VALUE2 <> ""]]></SetProperty>
    <SetProperty Id="PROP2" Action="SetPROP2_1" After='SetPROP1_0' Value="[PROP1]"></SetProperty>

你不能。意思是,您必须提前设置属性(大概在那些 "previous dialogs" 中),在 windows 安装程序中没有类似 "form.onload" 的事件。

这就是它的真谛 - "designed by the most enlightened architectural astronauts, implemented by the worst coders" (c) - 这当然是一个悲伤的笑话,但部分是真的。必须真正开明才能让我们使用关系数据库表设计用户界面。

MSI 对话行为是发布不在范围内,直到您转换到下一个对话。所以通常的解决方法是将您的控件拆分到不同的屏幕上。 WiX 维护 UI(修复、更改、删​​除)以这种方式工作。他们没有使用收音机并停留在同一屏幕上,而是使用发布按钮然后转换到可以使用它们的下一个对话框。然后,您还可以在按钮上放置漂亮的图标,这是单选无法做到的。