WiX: property value lost between InstallUISequence

2019-06-20 04:30发布

问题:

I'm facing an issue with my WiX installer.

I have a custom dialog that contains an edit control linked to a property. At runtime, if I change the value in the edit control, I see from the log that the property is properly updated with that new value. But it seems that, when the InstallUISequence ends, the property is reset to its default value, which is annoying, because I cannot use the user sumitted value in a custom action part of the InstallExecuteSequence.

Here is an extract of the WXS script I use:

<UI>
    <Dialog Id="select_list" Width="370" Height="270" Title="Select license and list files">
        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="UIBannerBmp" />
        <Control Id="BannerLine" Type="Line" X="0" Y="45" Width="370" Height="0" />
        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
        <Control Type="Edit" Id="list" Width="211" Height="15" X="128" Y="128" Property="pListFile" />
        <Control Type="Text" Id="static_list" Width="78" Height="17" X="41" Y="154" Text="list file" />
        <Control Type="PushButton" Id="next" Width="50" Height="17" X="232" Y="244" Text="Next &gt;">
            <Publish Event="EndDialog" Value="Return">1</Publish>
        </Control>
        <Control Type="PushButton" Id="cancel" Width="50" Height="17" X="296" Y="244" Text="Cancel">
            <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>
        <Control Type="Text" Id="desc" Width="348" Height="16" X="8" Y="90"
                 Text="Please set the path of the the list file" />
    </Dialog>

    <InstallUISequence>
        <Show Dialog="select_list" After="WelcomeEulaDlg">NOT installed</Show>
    </InstallUISequence>
</UI>

<CustomAction Id="InstallService"
              ExeCommand="[bin]prog.exe -f install.cl '[pListFile]'"
              Execute="immediate"
              Return="check"
              Directory="bin" />

<InstallExecuteSequence>
    <Custom Action="InstallService" After="InstallFinalize">REMOVE=""</Custom>
</InstallExecuteSequence>

<CustomActionRef Id="InstallService" />
<Property Id="pListFile" Value="c:\" />

I must not be on the right track to exchange information between the two sequences.

Is there a way to do that?

回答1:

You need to mark the Property "Secure" for it to pass from the client-side (InstallUISequence) to server-side (InstallExecuteSequence). To do that you need to make the Property "public" (ALL CAPS) and secure. Something like so:

<Property Id="PLISTFILE" Secure="yes"/>

You don't need to give it a value unless you want something to show up by in your UI by default.