我正在使用WiX Toolset编写Windows Installer程序包。我的应用程序集成了Windows Forms WebBrowser控件 - 基本上是Internet Explorer - 我需要在安装程序中确保最低版本的Internet Explorer。我没有在WiX中找到一个简单的内置方法来检查Internet Explorer版本(与.NET Framework一样),因此我正在关注WiX教程instructions for checking a file's version number during installation以及Microsoft&# 39; s documentation of Internet Explorer version numbers(标题下,如何确定适用于Windows的Internet Explorer版本,第三个项目符号点。)
以下是我的Product.wxs文件中的相关代码,其中包含说明性注释:
<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日志文件的摘录,显示了搜索文件,插入了星号以指出重要的行:
Action 22:10:12: AppSearch. Searching for installed applications Action start 22:10:12: AppSearch. ★AppSearch: Property: IE10ORHIGHER, Signature: ProgFolder AppSearch: Property: NETFRAMEWORK45, Signature: NetFramework45 MSI (c) (BC:54) [22:10:12:849]: PROPERTY CHANGE: Adding NETFRAMEWORK45 property. Its value is '#379893'. Action ended 22:10:12: AppSearch. Return value 1. MSI (c) (BC:54) [22:10:12:849]: Doing action: LaunchConditions MSI (c) (BC:54) [22:10:12:849]: Note: 1: 2205 2: 3: ActionText Action 22:10:12: LaunchConditions. Evaluating launch conditions Action start 22:10:12: LaunchConditions. MSI (c) (BC:48) [22:10:12:856]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg ★This application requires Internet Explorer 10 or higher. Please upgrade Internet Explorer, and then run this installer again. MSI (c) (BC:54) [22:10:14:276]: Note: 1: 2205 2: 3: Error MSI (c) (BC:54) [22:10:14:276]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709 ★MSI (c) (BC:54) [22:10:14:276]: Product: MyProductName -- This application requires Internet Explorer 10 or higher. You have installed. Please upgrade Internet Explorer, and then run this installer again. Action ended 22:10:14: LaunchConditions. Return value 3. Action ended 22:10:14: INSTALL. Return value 3. Property(C): UpgradeCode = {MY-GUID-REMOVED} Property(C): NETFRAMEWORK45 = #379893
相比之下,当我使用省略的FileSearch元素的MinVersion属性重新编译时,这是来自安装的日志文件。在这种情况下,肯定会找到iexplore.exe文件,该属性已设置,程序安装正常(但当然,这省略了我需要完成的版本检查!)
Action start 21:40:48: AppSearch. AppSearch: Property: IE10ORHIGHER, Signature: ProgFolder ★MSI (c) (98:14) [21:40:48:761]: PROPERTY CHANGE: Adding IE10ORHIGHER property. Its value is 'C:\Program Files\Internet Explorer\iexplore.exe'. AppSearch: Property: NETFRAMEWORK45, Signature: NetFramework45 MSI (c) (98:14) [21:40:48:762]: PROPERTY CHANGE: Adding NETFRAMEWORK45 property. Its value is '#379893'. Action ended 21:40:48: AppSearch. Return value 1. MSI (c) (98:14) [21:40:48:762]: Doing action: LaunchConditions MSI (c) (98:14) [21:40:48:762]: Note: 1: 2205 2: 3: ActionText Action 21:40:48: LaunchConditions. Evaluating launch conditions Action start 21:40:48: LaunchConditions. Action ended 21:40:48: LaunchConditions. Return value 1. ★★★Numerous lines about the installation's progress skipped here★★★ Property(C): UpgradeCode = {MY-GUID-REMOVED} ★Property(C): IE10ORHIGHER = C:\Program Files\Internet Explorer\iexplore.exe Property(C): NETFRAMEWORK45 = #379893
为什么我的FileSearch无法识别iexplore.exe的11.0.9600.17840版本大于MinVersion属性的值10.0.9200.16383?
为了回应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"
OR
解决方法/测试2 - 指定每台计算机的安装
msiexec /package MyProductName.msi ALLUSERS=1
找到问题的原因很好,但我仍然有问题。我的安装程序需要根据用户的选择在每个用户或每个计算机的上下文中运行。由于MSI的ProgramFilesFolder
变量特定于安装上下文,因此在每个用户上下文中运行时,如何在%ProgramFiles%
下测试IE的版本?
答案 0 :(得分:1)
你能尝试在测试项目中尝试做什么,看看它是否按预期工作?因为我在测试项目中尝试了一段代码并且按预期工作。 我使用了 Windows 7 64位环境,我系统上的iexplore.exe版本是11.0.9600.17937 。如果我在MinVersion字段中使用11.0.9600.17937,我会看到消息(即最低要求找不到版本11.0.9600.1793 8 。如果我在MinVersion字段中使用11.0.9600.17936,我看不到该消息(即最低要求版本11.0.9600.1793 7 已被发现)如果它是Windows 7或Windows 8环境,这种行为是由Windows安装程序框架决定的,这并不重要。 顺便说一下,当你说版本检查被省略时你是什么意思? 如果找不到所需的最低版本的Internet Explorer,您将只会看到启动条件。只要日志指示: LaunchConditions。评估启动条件,其安全性足以假设正在执行版本检查。
这是我的测试项目:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="FileSearch" Language="1033" Version="1.0.0.0" Manufacturer="Test" UpgradeCode="8790de3a-ca66-4577-b3cd-5a9df0ab15b2">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="FileSearch" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<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="11.0.9600.17936" />
</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>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="FileSearch" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="ProductComponent" Guid="{6CD6FBF0-8FE4-4882-80E1-DC16B9CED222}">
<!-- TODO: Insert files, registry keys, and other resources here. -->
<File Id="ProductFile" KeyPath="yes" Source="E:\Learning\Test Projects\Files\abc.dll" Name="abc.dll" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
答案 1 :(得分:1)
我不能重复你的问题,它对我有用。你是在合并模块中做这个吗?如果是这样,ProgramFilesFolder将被模块化,并且不会解析到你认为它将会存在的目录,除非你排除它。
通常,当涉及签名表(文件搜索)时,要知道的是它需要考虑语言,并且如果您没有指定它,则不包含边界。参见:
注意语言列中指定的语言用于 比较并没有办法忽视语言。如果你想要一个文件 无论语言如何,满足MinVersion字段要求 必须在MinVersion字段中输入一个小于1的值 实际价值。例如,如果过滤器的最小版本是 2.0.2600.1183,使用2.0.2600.1182查找文件而不匹配语言信息。