Wix,存在先前版本时的自定义对话框 [英] Wix, custom dialog when previous version exists

查看:105
本文介绍了Wix,存在先前版本时的自定义对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WiX工具集为我的应用程序进行安装. 如果找到以前的版本,我想显示自定义对话框.

I'm making installation for my application with WiX toolset. I want to show custom dialog if previous version found.

现在我不知道如何检查是否有以前的版本,并且仅在这种情况下才显示此对话框? 这是我的代码.

Now I don't know how to check if there is previous version and show this dialog only in that case? Here is my code.

CustomDialogUI.wxs:

CustomDialogUI.wxs :

 <?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <UI>
  <Dialog Id="OldVersionDlg" Width="260" Height="85" Title="[ProductName] Setup" NoMinimize="yes">
    <Control Id="No" Type="PushButton" X="132" Y="57" Width="56" Height="17"
      Default="yes" Cancel="yes" Text="No">
      <Publish Event="EndDialog" Value="Exit">1</Publish>
    </Control>
    <Control Id="Yes" Type="PushButton" X="72" Y="57" Width="56" Height="17" Text="Yes">
      <Publish Event="EndDialog" Value="Return">1</Publish>
    </Control>
    <Control Id="Text" Type="Text" X="5" Y="15" Width="250" Height="30">
      <Text>A previous version of [ProductName] is currently installed. By continuing the installation this version will be uninstalled. Do you want to continue?</Text>
    </Control>

  <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
    <Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
  </Control>
  <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
    <Publish Event="ValidateProductID" Value="0">1</Publish>
    <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
    <Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</Publish>
  </Control>
  <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
    <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
  </Control>

  <Control Id="BannerLine" Type="Line" X="0" Y="50" Width="370" Height="0" />
  </Dialog>      
</UI>

以此,我根据需要创建了对话框,并将其插入到原始对话框链中.

With this I have created my dialog as I wanted and inserted into the original chain of dialogs.

在我的Project.wxs中

And in my Project.wxs

<UI Id="MyWixUI_Mondo">
      <UIRef Id="WixUI_Mondo" />
      <UIRef Id="WixUI_ErrorProgressText" />

  <DialogRef Id="OldVersionDlg" />

  <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="OldVersionDlg" Order="3">LicenseAccepted = "1"</Publish>
  <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="OldVersionDlg">1</Publish>
</UI>

有了这个,我每次都会得到OldVErsionDlg,而且我不知道如何让他仅在存在先前版本的情况下显示.

With this I get my OldVErsionDlg everytime, and I don't know how to make him show ONLY if previous version exists.

我已添加到Project.wxs

I have added to Project.wxs

<Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
<Upgrade Id="{80EE38CE-1A3B-445F-8CC1-31B32AA77715}">
  <UpgradeVersion Minimum="1.0.0.0" Maximum="9.0.0.0"
                  Property="PREVIOUSVERSIONSINSTALLED"
                  IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>

并尝试:

 <UI Id="MyWixUI_Mondo">
  <UIRef Id="WixUI_Mondo" />
  <UIRef Id="WixUI_ErrorProgressText" />

  <DialogRef Id="OldVersionDlg" />

  <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="OldVersionDlg" Order="3">LicenseAccepted = "1" AND PREVIOUSVERSIONSINSTALLED</Publish>
  <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="OldVersionDlg">1</Publish>
</UI>

没有运气.

推荐答案

下一步/后退按钮替代 :我不是GUI专家,实际上这是一个被忽略的领域(对于公司部署,始终禁止使用GUI),但我相信这样可以起作用-重新定义下一步"和后退"按钮-涉及3个对话框:

Next / Back Button Override: I am no GUI expert, in fact it is a neglected area (GUI is always suppressed for corporate deployment), but I believe something like this can work - redefining the Next and Back buttons - 3 dialogs involved:

<!-- 1. OldVersionDlg showing -->
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" 
         Value="OldVersionDlg">LicenseAccepted = "1" AND PREVIOUSVERSIONSINSTALLED</Publish>

<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" 
         Value="OldVersionDlg">PREVIOUSVERSIONSINSTALLED</Publish>

<!-- 2. OldVersionDlg dialog not showing -->
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" 
         Value="SetupTypeDlg">LicenseAccepted = "1" AND NOT PREVIOUSVERSIONSINSTALLED</Publish>

<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" 
         Value="LicenseAgreementDlg">NOT PREVIOUSVERSIONSINSTALLED</Publish>

实际对话框序列 :

Actual Dialog Sequences:

  1. LicenseAgreementDlg <-> OldVersionDlg <-> SetupTypeDlg

  1. LicenseAgreementDlg <-> OldVersionDlg <-> SetupTypeDlg

LicenseAgreementDlg <-> SetupTypeDlg

LicenseAgreementDlg <-> SetupTypeDlg

当然,请记住要在所有安装模式下进行测试:installupgraderepairmodifypatchinguninstall(而且有些陌生的地方,例如恢复安装-很少看到).

To be sure, remember to test in all installation modes: install, upgrade, repair, modify, patching, uninstall (and there are stranger shores such as resumed installs - rarely seen).

结束语 :此功能真的必要吗?我发现类似这样的功能通常会导致更多的错误而不是好处,但这只是个人观点.实际上,很久以前,我就如何实现这样的不使用安装对话框的升级检查写了一个答案.

某些链接 :

Some Links:

  • Changing text color to Wix dialogs (Customizing WiX GUI)
  • Wix default folder dialog

这篇关于Wix,存在先前版本时的自定义对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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