wix从单选按钮

时间:2016-08-02 09:07:38

标签: wix wix3 wix3.8

我尝试使用单选按钮设置两个不同的安装位置(单个用户安装到AppData,allusers安装到ProgramFiles)

我的属性定义如下:

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

我的安装目录定义如下:

    <Directory Id='TARGETDIR' Name='SourceDir'>
        <Directory Id= 'INSTALLSCOPE'  Name='AppData'>
            <Directory Id='MYAPP' Name='COMPANY'>
                <Directory Id='INSTALLDIR' Name='MyApp'>

我的单选按钮如下:

    <Dialog Id="CustomInstallScopeDlg" Width="370" Height="270" Title="[ProductName] Install Scope"
                NoMinimize="yes">

        <Control Id="RadioButtonGroupID" Type="RadioButtonGroup" X="30" Y="94" Width="305" Height="100" Property="INSTALLSCOPE">

            <RadioButtonGroup Property="INSTALLSCOPE">
                <RadioButton Value="LocalAppDataFolder" X="0" Y="0" Width="300" Height="10" Text="SingleUser"/>
                <RadioButton Value="ProgramFilesFolder" X="0" Y="20" Width="300" Height="10" Text="AllUser"/>
            </RadioButtonGroup>

        </Control>
            ...

更改单选按钮并单击“下一步”按钮后,会发生以下情况:

    <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes"
    Text="[ButtonText_Next]">
            <Publish Property="INSTALLSCOPE" Value="LocalAppDataFolder">INSTALLSCOPE = "LocalAppDataFolder"</Publish>
            <Publish Property="INSTALLSCOPE" Value="ProgramFilesFolder">INSTALLSCOPE = "ProgramFilesFolder"</Publish>
    </Control>

目前我运行它时发生的是它尝试安装在E:AppData中,而不是正确的AppData文件夹。此外,安装程序错误,UI没有显示。如果我对值LocalAppDataFolder进行硬编码而不是将其传递给变量,则不会发生这种情况。我在安装过程中运行了一个日志,我可以看到INSTALLSCOPE的值在我浏览安装程序时被更改,但UI从未更新以反映此更改,实际安装路径也不会发生变化。任何帮助都会很棒。

1 个答案:

答案 0 :(得分:0)

添加SetTargetPath事件:

<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes"
    Text="[ButtonText_Next]">
    <Publish Property="INSTALLSCOPE" Value="LocalAppDataFolder">INSTALLSCOPE = "LocalAppDataFolder"</Publish>
    <Publish Property="INSTALLSCOPE" Value="ProgramFilesFolder">INSTALLSCOPE = "ProgramFilesFolder"</Publish>
    <Publish Event="SetTargetPath" Value="INSTALLSCOPE">1</Publish>
</Control>