如何在Wix中显示操作系统的非阻塞警告?

如何在Wix中显示操作系统的非阻塞警告?,wix,windows-installer,Wix,Windows Installer,我已经阻止将我们的软件安装在操作系统上,因为在这些操作系统中,我们的软件不会像这样工作: <Condition Message="This software needs Windows XP or newer."> <![CDATA[VersionNT >= 501]]> </Condition> <SetProperty Id="OSWarningText" After="SetOSWarningText2" Value="

我已经阻止将我们的软件安装在操作系统上,因为在这些操作系统中,我们的软件不会像这样工作:

<Condition Message="This software needs Windows XP or newer.">
   <![CDATA[VersionNT >= 501]]>
</Condition>
  <SetProperty Id="OSWarningText" After="SetOSWarningText2"
     Value="[OSWarningText1][OSWarningText2]" />    
        <Publish Dialog="WelcomeDlg" Control="Next"
            Property="WelcomeDlg_Next" Value="{}"
            Order="1">1</Publish>
        <Publish Dialog="WelcomeDlg" Control="Next"
            Property="WelcomeDlg_Next" Value="WarningDlg"
            Order="2">OSWarningText</Publish>
        <Publish Dialog="WelcomeDlg" Control="Next"
            Property="WelcomeDlg_Next" Value="LicenseAgreementDlg"
            Order="3">NOT OSWarningText</Publish>
        <Publish Dialog="WelcomeDlg" Control="Next"
            Event="NewDialog" Value="[WelcomeDlg_Next]"
            Order="4">WelcomeDlg_Next</Publish>

= 501]]>
现在,如果用户试图在不明确支持的操作系统(VersionNT+Service Pack)上安装软件,即使该软件可以工作,我也希望显示一个非阻塞警告

例如,我们只明确支持每个操作系统的最新service pack


如何显示这样的警告?

我分三个部分解决了这个问题:

  • 定义OSWarningText属性 仅当出现警告时才设置 需要给予
  • 编写自定义警告屏幕
  • 如有必要,在UI序列中插入自定义警告屏幕
  • 1。定义OSWarningText属性

    首先,声明属性并默认为“unset”值:

      <Property Id="OSWarningText" Value="{}"/>
    
    我们的想法是创造这样的东西:

    <Condition Message="This software needs Windows XP or newer.">
       <![CDATA[VersionNT >= 501]]>
    </Condition>
    
      <SetProperty Id="OSWarningText" After="SetOSWarningText2"
         Value="[OSWarningText1][OSWarningText2]" />    
    
            <Publish Dialog="WelcomeDlg" Control="Next"
                Property="WelcomeDlg_Next" Value="{}"
                Order="1">1</Publish>
            <Publish Dialog="WelcomeDlg" Control="Next"
                Property="WelcomeDlg_Next" Value="WarningDlg"
                Order="2">OSWarningText</Publish>
            <Publish Dialog="WelcomeDlg" Control="Next"
                Property="WelcomeDlg_Next" Value="LicenseAgreementDlg"
                Order="3">NOT OSWarningText</Publish>
            <Publish Dialog="WelcomeDlg" Control="Next"
                Event="NewDialog" Value="[WelcomeDlg_Next]"
                Order="4">WelcomeDlg_Next</Publish>
    

    3。在UI序列中插入自定义警告屏幕

    现在,我们需要确保警告屏幕显示在欢迎对话框和许可协议对话框之间,但前提是确实有警告要显示。这是更一般问题的一个特例

    同样,从wix源复制预定义的UI序列,例如
    WixUI\u InstallDir.wxs
    ,并将UI ID重命名为
    ID=“MyWixUI”
    。在主wxs文件中将其引用为
    。现在查找并编辑WelcomeDlg next按钮的事件处理程序

    您可以设置属性以响应按钮按下和附加条件,并且可以基于属性显示下一个对话框。我们将利用它来处理WelcomeDlg next按钮,如下所示:

    <Condition Message="This software needs Windows XP or newer.">
       <![CDATA[VersionNT >= 501]]>
    </Condition>
    
      <SetProperty Id="OSWarningText" After="SetOSWarningText2"
         Value="[OSWarningText1][OSWarningText2]" />    
    
            <Publish Dialog="WelcomeDlg" Control="Next"
                Property="WelcomeDlg_Next" Value="{}"
                Order="1">1</Publish>
            <Publish Dialog="WelcomeDlg" Control="Next"
                Property="WelcomeDlg_Next" Value="WarningDlg"
                Order="2">OSWarningText</Publish>
            <Publish Dialog="WelcomeDlg" Control="Next"
                Property="WelcomeDlg_Next" Value="LicenseAgreementDlg"
                Order="3">NOT OSWarningText</Publish>
            <Publish Dialog="WelcomeDlg" Control="Next"
                Event="NewDialog" Value="[WelcomeDlg_Next]"
                Order="4">WelcomeDlg_Next</Publish>
    
  • 重置WelcomedLog\u下一个属性 “取消设置”
  • 将WelcomeDlg\u Next属性设置为 “警告DLG”,但前提是 OSWarningText已设置
  • 将WelcomeDlg\u Next属性设置为 “许可协议DLG”,但仅当 未设置OSWarningText
  • 显示由给定的对话框 下一步,如果财产是 设置正确
  • 要执行此操作的Wix代码如下所示:

    <Condition Message="This software needs Windows XP or newer.">
       <![CDATA[VersionNT >= 501]]>
    </Condition>
    
      <SetProperty Id="OSWarningText" After="SetOSWarningText2"
         Value="[OSWarningText1][OSWarningText2]" />    
    
            <Publish Dialog="WelcomeDlg" Control="Next"
                Property="WelcomeDlg_Next" Value="{}"
                Order="1">1</Publish>
            <Publish Dialog="WelcomeDlg" Control="Next"
                Property="WelcomeDlg_Next" Value="WarningDlg"
                Order="2">OSWarningText</Publish>
            <Publish Dialog="WelcomeDlg" Control="Next"
                Property="WelcomeDlg_Next" Value="LicenseAgreementDlg"
                Order="3">NOT OSWarningText</Publish>
            <Publish Dialog="WelcomeDlg" Control="Next"
                Event="NewDialog" Value="[WelcomeDlg_Next]"
                Order="4">WelcomeDlg_Next</Publish>
    
    1
    OSWarningText
    不是OSWarningText
    欢迎下一位
    
    然后对许可协议“返回”按钮执行等效操作:如果没有警告,则应返回欢迎屏幕,否则返回警告屏幕