自定义 Wix UI 中的 InstallScopeDlg 不起作用

Posted

技术标签:

【中文标题】自定义 Wix UI 中的 InstallScopeDlg 不起作用【英文标题】:InstallScopeDlg in Custom Wix UI not working 【发布时间】:2015-05-26 06:28:23 【问题描述】:

嗨,我已经使用 wix 开发了一个设置,现在我需要询问用户是它的 AllUser 还是 perUser。经过长时间的研究,我发现 InstallScopeDLg 可以使它成为可能。但是我已经用我的 wix 添加了自定义 UI,我没有无法在 WIX 中使用此自定义 UI 添加 InstallScopeDlg。

    <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
        <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="ReadmeDlg" Order="2">LicenseAccepted = "1"</Publish>

      <Publish Dialog="MyInstallScopeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
      <Publish Dialog="MyInstallScopeDlg" Control="Next" Event="NewDialog" Value="ReadmeDlg" Order="2"></Publish>


      <Publish Dialog="ReadmeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
        <Publish Dialog="ReadmeDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="2"></Publish>

这是我的 InstallScopeDlg 代码

<?xml version="1.0" encoding="UTF-8"?><!--
Copyright (c) Microsoft Corporation.  All rights reserved.-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <UI>
  <Dialog Id="MyInstallScopeDlg" Width="370" Height="270" Title="!(loc.InstallScopeDlg_Title)" KeepModeless="yes">
    <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallScopeDlgBannerBitmap)" />
    <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
    <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
    <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="20" Transparent="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgDescription)" />
    <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgTitle)" />
    <Control Id="BothScopes" Type="RadioButtonGroup" X="20" Y="55" Width="330" Height="120" Property="WixAppFolder" Hidden="yes">
      <RadioButtonGroup Property="WixAppFolder">
        <RadioButton Value="WixPerUserFolder" X="0" Y="0" Width="295" Height="16" Text="!(loc.InstallScopeDlgPerUser)" />
        <RadioButton Value="WixPerMachineFolder" X="0" Y="60" Width="295" Height="16" Text="!(loc.InstallScopeDlgPerMachine)" />
      </RadioButtonGroup>
      <Condition Action="show">Privileged AND (!(wix.WixUISupportPerUser) AND !(wix.WixUISupportPerMachine))</Condition>
    </Control>
    <Control Id="PerUserDescription" Type="Text" X="33" Y="70" Width="300" Height="36" Hidden="yes" Text="!(loc.InstallScopeDlgPerUserDescription)">
      <Condition Action="show">!(wix.WixUISupportPerUser)</Condition>
    </Control>
    <Control Id="NoPerUserDescription" Type="Text" X="33" Y="70" Width="300" Height="36" Hidden="yes" Text="!(loc.InstallScopeDlgNoPerUserDescription)">
      <Condition Action="show">NOT !(wix.WixUISupportPerUser)</Condition>
    </Control>
    <Control Id="PerMachineDescription" Type="Text" X="33" Y="131" Width="300" Height="36" Hidden="yes" Text="!(loc.InstallScopeDlgPerMachineDescription)">
      <Condition Action="show">Privileged</Condition>
    </Control>
    <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
    <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
    <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
      <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
    </Control>
  </Dialog>
</UI>

对于 RadioButtonGroup Property="WixAppFolder" 在 InstallScopeDlg

我已经在 product.wxs 文件中添加了

我得到的错误代码为

错误 10 Windows 安装程序 XML 变量 !(wix.WixUISupportPerUser) 未知。请确保变量是 通过 WixVariable 元素在 light.exe 的命令行上声明, 或使用语法内联 !(wix.WixUISupportPerUser=some value which 不包含括号)。

【问题讨论】:

【参考方案1】:

因此,我们首先需要在 myinstallscopedlg.wxs 的片段部分下声明其组件

     <?xml version="1.0" encoding="UTF-8"?><!--
Copyright (c) Microsoft Corporation.  All rights reserved.-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>

    <WixVariable Id="WixUISupportPerUser" Value="1" Overridable="yes" />
    <WixVariable Id="WixUISupportPerMachine" Value="1" Overridable="yes" />

          <UI>
                <Dialog Id="MyInstallScopeDlg" Width="370" Height="270" Title="!(loc.InstallScopeDlg_Title)" KeepModeless="yes">

通过执行此错误 Windows Installer XML 变量 !(wix.WixUISupportPerUser) 未知。 将得到解决

【讨论】:

以上是关于自定义 Wix UI 中的 InstallScopeDlg 不起作用的主要内容,如果未能解决你的问题,请参考以下文章

UI序列中的Wix进度条

如何防止 wix 自定义引导程序卸载 UI 在升级过程中显示

Wix3.7 自定义引导程序不显示主题库中的 WPF 主题

Windows Installer XML (WiX):添加自定义对话框

WiX:使用msiexec / i Setup.msi / qn时不运行自定义操作(没有UI的安静模式安装)

WiX:如何在升级期间显示 EULA 协议 UI?