Wix - 基于单选按钮有条件地安装功能 [英] Wix - Conditional install of features based on radio buttons

查看:27
本文介绍了Wix - 基于单选按钮有条件地安装功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习使用 WiX 工具为我工作的软件应用程序设置 MSI 包.

I am currently learning about the WiX tool to set up MSI packages for the software applications we have where I work.

作为安装的一部分,我想做的一件事是提供一个要安装的特定文件的选择,我将有一个带有单选按钮列表的对话框,以允许用户选择所需的选项.

One of the things I wanted to do as part of an installation is offer a choice of a particular file to be installed, and I was going to have a dialog with a list of radio buttons, to the allow the user to select the required option.

这是我正在使用的 WXS 文件

Here is the WXS file I am using

<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:iis='http://schemas.microsoft.com/wix/IIsExtension'>
  <Product Id='E22E3B45-CFA6-4F4E-9D37-AA95A3684522' Name='Test Install' Language='1033'
           Version='1.0.0.0' Manufacturer='Microsoft Corporation' UpgradeCode='E22E3B45-CFA6-4F4E-9D37-AA95A3684522'>
    <Package Description='Test Installer Package'
              Comments='Install Test'
              Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />

    <Media Id='1' Cabinet='testinstall.cab' EmbedCab='yes' />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='dir_temp' Name='Temp'>
        <Component Id='component_dir_root1' Guid='A51094B8-552F-49C4-9E5C-36815D471913'>
          <File Id='file_readme.txt' Name='readme.txt' DiskId='1' Source='root/readme.txt' />
        </Component>
        <Component Id='component_dir_root2' Guid='A51094B8-552F-49C4-9E5C-36815D471914'>
          <File Id='file_readme2.txt' Name='readme2.txt' DiskId='1' Source='root/readme2.txt' />
        </Component>
      </Directory>
    </Directory>

    <Feature Id='feature_test' Title='Test Features' Level='1'>
      <Feature Id='feature_dir_root1' Level='1'>
        <ComponentRef Id='component_dir_root1' />
        <Condition Level="0"><![CDATA[RootType <> "1"]]></Condition>
      </Feature>
      <Feature Id='feature_dir_root2' Level='1'>
        <ComponentRef Id='component_dir_root2' />
        <Condition Level="0"><![CDATA[RootType <> "2"]]></Condition>
      </Feature>
    </Feature>

    <UI>
      <Property Id="DefaultUIFont">DlgFont8</Property>

      <Dialog Id="InstallDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">
    <Control Id="Buttons" Type="RadioButtonGroup" X="20" Y="187" Width="330" Height="40" Property="RootType" />

        <Control Id="Install" Type="PushButton" X="304" Y="243" Width="56" Height="17" Default="yes" Text="Install">
          <Publish Event="EndDialog" Value="Return" />
        </Control>
      </Dialog>

      <RadioButtonGroup Property="RootType">
        <RadioButton Text="{\DlgFont8}Root 1"
          Value="1" X="5" Y="0" Width="250" Height="15" />
        <RadioButton Text="{\DlgFont8}Root2"
          Value="2" X="5" Y="20" Width="250" Height="15" />
      </RadioButtonGroup>

      <TextStyle Id="DlgFont8" FaceName="Tahoma" Size="8" />

      <InstallUISequence>
        <Show Dialog="InstallDlg" After="CostFinalize" />
      </InstallUISequence>
    </UI>

    <Property Id="RootType">2</Property>
  </Product>
</Wix>

因此,存在两个特征.每个对应于代表文件的单个组件.单选按钮链接到 RootType 属性,我想控制安装哪个功能.

So, there are two features present. Each corresponding to an individual component representing the files. The radio buttons link to a RootType property which I want to control which feature is installed.

对话框显示正常,如果我更改 RootType 的默认值,则在显示安装表单时始终会选中正确的单选按钮.但是,如果用户在安装过程中选择了不同的单选按钮,实际上对安装的文件没有任何影响.安装的文件始终是设置为 RootType 属性初始值的文件.

The dialog is shown fine, and if I vary the default value of the RootType the correct radio button is always checked when the installation form is shown. However, if a different radio button is selected by the user during installation, it doesn't actually make any different to which file gets installed. The file that gets installed is always the one that is set as the initial value of the RootType property.

在安装功能之前,是否还需要执行其他操作来获取单选按钮以更新属性?

Is there something else that needs to be done to get the radio buttons to update the property before the features are installed?

推荐答案

当您的对话框显示时,设置属性以影响 INSTALLLEVEL 的功能条件为时已晚.相反,您应该将 Control Events 放在对话框的 Next(或类似)按钮上,并使用使用 AddLocal 或 Remove 来控制是否安装该功能的单选按钮.

By the time your dialogs are shown, it's too late to set properties to influence feature conditions against INSTALLLEVEL. Instead you should put Control Events on the Next (or similar) button on the dialog with the radio buttons that use AddLocal or Remove to control whether the feature gets installed.

这篇关于Wix - 基于单选按钮有条件地安装功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆