WiX 安装程序 - 更新场景自定义 UI

发布于 2024-08-28 01:08:23 字数 308 浏览 2 评论 0原文

对于我的应用程序,我有一个使用 WiX 开发的 .msi。对于更新场景,我想要执行以下操作:

  • 如果安装的版本永远不会比更新版本显示错误

  • 如果安装版本早于更新版本 显示带有文本 Update

    的按钮
  • 如果安装的版本与更新版本相同,则显示带有文本 Repair

    的按钮

我已经找到了如何定义自定义 UI 对话框,但是如果我创建一个包含所有这些控件(错误标签、更新/修复按钮)的对话框,我如何根据情况仅显示适当的控件。

For my application I have an .msi developed with WiX. For the update scenario I want to do the following:

  • if the installed version is never than the update version display an error

  • if the installed version is older than the update version show a button with text Update

  • if the installed version is the same as the update version show a button with text Repair

I have found how to define custom UI dialogs, but if I create a dialog with all these controls (Error label, Update/Repair buttons) how can I display just the appropriate one according to the situation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

提笔落墨 2024-09-04 01:08:23

使用升级属性。

假设

<Product Version="1.0.0.0" />

第一个升级版本找到

<Upgrade Id="GUID">
  <UpgradeVersion OnlyDetect="no" Property="OLDERFOUND" Maximum="1.0.0.0" IncludeMaximum="no" />
  <UpgradeVersion OnlyDetect='yes' Property='NEWERFOUND' Minimum="1.0.0.0" IncludeMinimum='no' />
  <UpgradeVersion OnlyDetect='yes' Property='SAMEFOUND' Minimum="1.0.0.0" Maximum='1.0.0.0' />
</Upgrade>

当前版本之前的所有版本

第二行找到当前版本之上的所有版本

第三行找到与当前版本相同的已安装版本

然后使用像这样的自定义操作

<CustomAction Id='NewerFound' Error='A later version of [ProductName] is already installed' />
<InstallExecuteSequence>
    <Custom Action='NewerFound' After='FindRelatedProducts'>NEWERFOUND</Custom>
    <RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>

显示的自定义操作要么删除旧版本自动更新版本,或者警告用户已安装更新版本,但如果您想提示用户,则可以显示自定义 UI 而不是运行 CA。

就我个人而言,我只使用前两条升级版本行。如果找到较旧的版本,则会自动升级;如果有较新的版本,则会向用户显示错误;如果安装了相同的版本,则会向用户显示错误(默认情况下,它不需要第三行) ,但是这并没有给你想要的 UI,所以正如我上面所说,尝试用你的 UI 替换这些 CA。

Use the Upgrade property.

Assuming

<Product Version="1.0.0.0" />

and

<Upgrade Id="GUID">
  <UpgradeVersion OnlyDetect="no" Property="OLDERFOUND" Maximum="1.0.0.0" IncludeMaximum="no" />
  <UpgradeVersion OnlyDetect='yes' Property='NEWERFOUND' Minimum="1.0.0.0" IncludeMinimum='no' />
  <UpgradeVersion OnlyDetect='yes' Property='SAMEFOUND' Minimum="1.0.0.0" Maximum='1.0.0.0' />
</Upgrade>

The first upgradeversion finds all versions upto the current one

the second line finds all versions above the current one

the third line finds installed versions the same as the current one

Then use a custom action like so

<CustomAction Id='NewerFound' Error='A later version of [ProductName] is already installed' />
<InstallExecuteSequence>
    <Custom Action='NewerFound' After='FindRelatedProducts'>NEWERFOUND</Custom>
    <RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>

etc

The custom actions shown either removes the older version automatically or it warns the user that a newer version is already installed, but if you want to prompt the user then you can show your custom UI instead of running the CAs.

Personally I just use the first two upgradeversion lines. This does the automatic upgrade if an older one is found, shows the user an error if there is a newer one and, if the same one is installed it shows the user an error ( it does that by default it doesnt require the third line), however this doesnt give you the UI like you want, so as I said above try replacing these CAs with your UI.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文