【发布时间】:2015-08-17 03:30:39
【问题描述】:
我正在使用WiX Toolset 编写Windows 安装程序包。我的应用程序与 Windows 窗体 WebBrowser 控件(基本上是 Internet Explorer)集成在一起,我需要确保安装程序中的 Internet Explorer 版本最低。我没有在 WiX 中找到一种简单的内置方法来检查 Internet Explorer 版本(与 .NET Framework 一样),所以我正在关注 WiX 教程的 instructions for checking a file's version number during installation 以及 Microsoft 的 documentation of Internet Explorer version numbers(在标题下) , 如何确定 Windows 版 Internet Explorer 的版本,第三个要点)。
这是我的 Product.wxs 文件中的相关代码,其中包含解释性 cmets:
<Property Id="IE10ORHIGHER">
<DirectorySearch Id="ProgFolder" Path="[ProgramFilesFolder]\Internet Explorer">
<!-- I tried the following line to ensure that my DirectorySearch Path
and FileSearch Name attributes were functioning correctly.
This line--without MinVersion set--results in the IE10ORHIGHER
property being defined during installation, but it is useless
because it merely detects that iexplore.exe exists rather than
ensuring a minimum version. -->
<!-- <FileSearch Name="iexplore.exe" /> -->
<!-- I need Internet Explorer 10 at minimum. -->
<!-- IE10 RTM for Windows 8 version number: 10.0.9200.16384 -->
<!-- IE10 RTM for Windows 7 version number: 10.0.9200.16521 -->
<!-- Use IE10 RTM for Windows 8 version string. Minimum in FileSearch
must be desired revision minus 1. See
https://msdn.microsoft.com/library/aa371853.aspx -->
<FileSearch Name="iexplore.exe" MinVersion="10.0.9200.16383" />
</DirectorySearch>
</Property>
<!-- Requires Internet Explorer 10 or higher. -->
<Condition Message="This application requires Internet Explorer 10 or higher. Please upgrade Internet Explorer, and then run this installer again.">
<![CDATA[Installed OR IE10ORHIGHER]]>
</Condition>
我正在运行 Windows 8.1,并且我已验证我系统上的 iexplore.exe 版本是 11.0.9600.17840。但是,当我使用完整日志记录 (/l*vx) 编译和运行安装程序时,会显示我的条件消息,并且未安装该软件。这是我的 MsiExec 日志文件的摘录,显示了对文件的搜索,并插入了星号以指出重要的行:
行动 22:10:12:AppSearch。搜索已安装的应用程序
行动开始 22:10:12:AppSearch。
★AppSearch:属性:IE10ORHIGHER,签名:ProgFolder
AppSearch:属性:NETFRAMEWORK45,签名:NetFramework45
MSI (c) (BC:54) [22:10:12:849]:属性更改:添加 NETFRAMEWORK45 属性。它的值为“#379893”。
行动于 22:10:12 结束:AppSearch。返回值 1。
MSI (c) (BC:54) [22:10:12:849]:执行操作:LaunchConditions
MSI (c) (BC:54) [22:10:12:849]: 注意: 1: 2205 2: 3: ActionText
行动 22:10:12:启动条件。评估发射条件
行动开始 22:10:12:LaunchConditions。
MSI (c) (BC:48) [22:10:12:856]:字体已创建。字符集:Req=0,Ret=0,字体:Req=MS Shell Dlg,Ret=MS Shell Dlg
★此应用程序需要 Internet Explorer 10 或更高版本。请升级 Internet Explorer,然后再次运行此安装程序。
MSI (c) (BC:54) [22:10:14:276]: 注意: 1: 2205 2: 3: 错误
MSI (c) (BC:54) [22:10:14:276]: 注意: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709
★MSI (c) (BC:54) [22:10:14:276]: Product: MyProductName -- 此应用程序需要 Internet Explorer 10 或更高版本。你已经安装了。请升级 Internet Explorer,然后再次运行此安装程序。
行动于 22:10:14 结束:LaunchConditions。返回值 3。
行动于 22:10:14 结束:安装。返回值 3。
属性(C):UpgradeCode = {MY-GUID-REMOVED}
属性(C):NETFRAMEWORK45 = #379893
相比之下,这是我重新编译时安装的日志文件,省略了 FileSearch 元素的 MinVersion 属性。在这种情况下,iexplore.exe文件肯定找到了,属性设置好了,程序安装正常(当然,这是省略了我需要完成的版本检查!)
动作开始时间 21:40:48:AppSearch。
AppSearch:属性:IE10ORHIGHER,签名:ProgFolder
★MSI (c) (98:14) [21:40:48:761]:属性更改:添加 IE10ORHIGHER 属性。它的值是'C:\Program Files\Internet Explorer\iexplore.exe'。
AppSearch:属性:NETFRAMEWORK45,签名:NetFramework45
MSI (c) (98:14) [21:40:48:762]:属性更改:添加 NETFRAMEWORK45 属性。它的值为“#379893”。
行动于 21:40:48 结束:AppSearch。返回值 1。
MSI (c) (98:14) [21:40:48:762]:执行操作:LaunchConditions
MSI (c) (98:14) [21:40:48:762]: 注意: 1: 2205 2: 3: ActionText
行动 21:40:48:启动条件。评估发射条件
行动开始时间 21:40:48:LaunchConditions。
行动于 21:40:48 结束:LaunchConditions。返回值 1。
★★★关于安装进度的多行此处略过★★★
属性(C):UpgradeCode = {MY-GUID-REMOVED}
★属性(C):IE10ORHIGHER = C:\Program Files\Internet Explorer\iexplore.exe
属性(C):NETFRAMEWORK45 = #379893
为什么我的 FileSearch 无法识别 iexplore.exe 的版本 11.0.9600.17840 大于 MinVersion 属性的值 10.0.9200.16383?
更新问题原因和修订问题 - 2015-08-25
为了响应Christopher Painter 和Kiran Hegde 的回答,我开始制作我的安装程序项目的最小版本,它仍然会显示错误。这样做,我发现了问题:我的安装程序是dual-purpose package;默认情况下,它按用户运行,因此指定Path="[ProgramFilesFolder]\Internet Explorer" 的 DirectorySearch 元素在%LOCALAPPDATA%\Programs 下搜索,而不是在%ProgramFiles% 下搜索。我通过在命令提示符下尝试以下解决方法/测试来验证是这种情况,这两种方法都允许安装程序成功完成:
解决方法/测试 1 - 将 IE 复制到安装程序正在查找的位置
robocopy "%ProgramFiles%\Internet Explorer" "%LOCALAPPDATA%\Programs\Internet Explorer" iexplore.exe
msiexec /package MyProductName.msi
rd /s /q "%LOCALAPPDATA%\Programs\Internet Explorer"
或
解决方法/测试 2 - 指定每台机器的安装
msiexec /package MyProductName.msi ALLUSERS=1
找到问题的原因很好,但我仍然有问题。我的安装程序需要根据用户的选择在每个用户或每个计算机的上下文中运行。由于 MSI 的 ProgramFilesFolder 变量特定于安装上下文,在每个用户上下文中运行时,我如何测试 %ProgramFiles% 下的 IE 版本?
【问题讨论】:
标签: wix windows-installer