WiX:如何在升级期间显示 EULA 协议 UI?
Posted
技术标签:
【中文标题】WiX:如何在升级期间显示 EULA 协议 UI?【英文标题】:WiX: How do I show the EULA agreement UI during an upgrade? 【发布时间】:2018-10-29 12:00:51 【问题描述】:我使用 WiX 创建和构建我的 Windows 应用 MSI 安装程序。我的 Product.wxs 文件具有以下结构来自定义安装程序,包括自定义 EULA 的显示:
<WixVariable Id="WixUIBannerBmp" Value="MyBanner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="MyDialog.bmp" />
<WixVariable Id="WixUIInfoIco" Value="MyIcon.ico" />
<WixVariable Id="WixUILicenseRtf" Value="MyEULA.rtf" />
它使用“InstallDir”内置 WiX UI 对话框集:
<UI>
<UIRef Id="WixUI_InstallDir" />
</UI>
这一切都适用于全新安装。
当我向我的应用程序发布升级时,迄今为止,我一直在使用以下命令在没有 UI 的情况下执行它作为升级过程的一部分:
msiexec /i MyInstaller.msi REINSTALL=ALL REINSTALLMODE=vemus /passive
我现在想更改我的 EULA,并且在下一次 [次要] 升级时,要求用户再次同意 EULA。我该怎么做?
(我从上面的命令中删除了/passive
开关,更新程序 MSI 现在有一个 UI,但它不显示 EULA 协议 UI - 它只在全新安装时显示。)
【问题讨论】:
我建议您让您的应用程序在首次启动时显示 EULA,而不是在设置中弄乱它。这也产生了更多的控制。当心在其他对话框下方显示您的对话框 - 可能会导致可怕的支持电话。 是的,那是我的备份解决方案。但我想通了 - 请参阅答案。 【参考方案1】:好的,我最终想通了,这远非显而易见或容易。
通过查看 GitHub 上的 WiX 帮助文件和 WiX 源文件,我想出了使用自定义 UI 构造填充 MSI“恢复对话框”(似乎用于小升级的情况)的解决方案显示 EULA 并要求协议(主要从 WiX 的 LicenseAgreementDlg 复制)。
所以,在Product.wxs
中,我在<UI>
标签之前添加了这一行:
<UIRef Id="WixUI_Common" />
然后,在<UI>
标签内,我替换了这一行:
<UIRef Id="WixUI_InstallDir" />
有了这个内容:
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<Property Id="WixUI_Mode" Value="InstallDir" />
<DialogRef Id="BrowseDlg" />
<DialogRef Id="DiskCostDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />
<DialogRef Id="PrepareDlg" />
<DialogRef Id="ProgressDlg" />
<!--<DialogRef Id="ResumeDlg" />-->
<Dialog Id="CustomResumeDlg" Width="370" Height="270" Title="!(loc.ResumeDlg_Title)">
<Control Id="Install" Type="PushButton" ElevationShield="yes" X="212" Y="243" Width="80" Height="17" Default="yes" Text="!(loc.ResumeDlgInstall)" Hidden="yes">
<Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1</Publish>
<Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
<Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
<Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
<Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
<Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
<Condition Action="show">ALLUSERS</Condition>
<Condition Action="disable"><![CDATA[UpgradeLicenseAccepted <> "1"]]></Condition>
<Condition Action="enable">UpgradeLicenseAccepted = "1"</Condition>
</Control>
<Control Id="InstallNoShield" Type="PushButton" ElevationShield="no" X="212" Y="243" Width="80" Height="17" Default="yes" Text="!(loc.ResumeDlgInstall)" Hidden="yes">
<Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1</Publish>
<Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
<Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
<Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
<Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
<Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
<Condition Action="show">NOT ALLUSERS</Condition>
</Control>
<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>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.LicenseAgreementDlgBannerBitmap)" />
<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="15" Y="6" Width="340" Height="32" Transparent="yes" NoPrefix="yes" Text="This Setup Wizard will upgrade the installation of [ProductName] on your computer. Click Install to continue or Cancel to exit the Setup Wizard." />
<Control Id="LicenseAcceptedCheckBox" Type="CheckBox" X="20" Y="207" Width="330" Height="18" CheckBoxValue="1" Property="UpgradeLicenseAccepted" Text="!(loc.LicenseAgreementDlgLicenseAcceptedCheckBox)" />
<Control Id="Print" Type="PushButton" X="112" Y="243" Width="56" Height="17" Text="!(loc.WixUIPrint)">
<Publish Event="DoAction" Value="WixUIPrintEula">1</Publish>
</Control>
<Control Id="LicenseText" Type="ScrollableText" X="20" Y="60" Width="330" Height="140" Sunken="yes" TabSkip="no">
<Text SourceFile="Resources\EULA.rtf" />
</Control>
</Dialog>
<InstallUISequence>
<Show Dialog="CustomResumeDlg" Before="ProgressDlg" Overridable="yes">Installed AND (RESUME OR Preselected)</Show>
</InstallUISequence>
<DialogRef Id="UserExit" />
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">LicenseAccepted = "1"</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1">NOT Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
<Property Id="ARPNOMODIFY" Value="1" />
此外,正如我的问题中所建议的,我确实必须从我的 msiexec
调用中删除 /passive
开关,以确保 UI 能够显示。
在此过程中学到了很多东西,我意识到可能还有另一种或更简单的方法可以做到这一点,但我对这个解决方案很满意。
【讨论】:
好的,如果部署是静默完成的,这显然是行不通的,这在所有公司环境中都是如此。 I have long argued that license dialogs and EULAs should be in the application instead of the setup - 也许有一个略读。显然还要在所有安装模式下进行测试:fresh install
、repair
、modify
、self-repair
、uninstall
、rollback
、minor upgrade
、major upgrade
和有或没有 patch packaging
。听起来你已经设置好了。修复、自我修复应该不涉及对话——只提这些模式。以上是关于WiX:如何在升级期间显示 EULA 协议 UI?的主要内容,如果未能解决你的问题,请参考以下文章