【问题标题】:Wix, custom dialog when previous version existsWix,以前版本存在时的自定义对话框
【发布时间】:2015-11-13 10:34:05
【问题描述】:

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

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

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>

有了这个,我创建了我想要的对话框并插入到原始的对话框链中。

在我的 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,我不知道如何让他只有在以前的版本存在时才显示。

我已经添加到 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>

不走运。

【问题讨论】:

    标签: user-interface installation wix wix3.10


    【解决方案1】:

    Next / Back Button Override:我不是 GUI 专家,实际上这是一个被忽视的领域(GUI 总是被企业部署抑制),但我相信一些像这样可以工作 - 重新定义“下一步”和“后退”按钮 - 涉及 3 个对话框:

    <!-- 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>
    

    实际的对话序列

    1. LicenseAgreementDlg &lt;-&gt; OldVersionDlg &lt;-&gt; SetupTypeDlg

    2. LicenseAgreementDlg &lt;-&gt; SetupTypeDlg

    可以肯定的是,请记住在所有安装模式下进行测试:installupgraderepairmodifypatchinguninstall(还有一些奇怪的支持,例如恢复安装 - 很少看过)。

    结束:这个功能真的有必要吗?我发现像这样的功能通常会导致比好处更多的错误,但这只是个人意见。其实我很久以前写过一个关于如何实现这样的an upgrade check without using setup dialogs的答案。


    一些链接

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多