2015-08-17 44 views
0

我正在使用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隨着微軟的documentation of Internet Explorer version numbers(標題下,如何確定Windows的Internet Explorer版本,第三個要點)。爲什麼FileSearch元素的MinVersion屬性在我的WiX安裝程序中不起作用?

這裏是我的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?


更新有問題的原因和經修訂的課題 - 2015年8月25日

在回答Christopher PainterKiran 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變量是特定於安裝上下文的,因此如何在每個用戶上下文中運行時測試IE版本%ProgramFiles%下的版本?

回答

1

你可以試試你在一個測試項目中試圖做的事情,看看它是否按預期工作?因爲我在測試項目中嘗試了一段代碼,並且按預期工作。我使用了一個的Windows 7 64位環境,並且我係統上的iexplore.exe版本是11.0.9600.17937。如果我在MinVersion字段中使用11.0.9600.17937,我會看到該消息(即所需的最低版本爲11.0 .9600.1793 未找到。如果我在MinVersion字段中使用11.0.9600.17936,我沒有看到該消息(即已找到所需的最低版本11.0.9600.1793 )應該無關緊要一個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> 
+0

我將您的代碼複製到一個新項目中,替換爲「E:\ Learning \ Test Projects \ Files \ abc.dll」中的「C:\ Windows \ System32 \ notepad.exe」。在我的機器上,Internet Explorer的版本是11.0.9600.17905。我使用MinVersion的以下值編譯並運行了此安裝程序三次:「11.0.9600.17905」,「11.0.9600.17904」和「11.0.9600.17900」。據我瞭解,第一個值應該導致消息出現(中止安裝),後兩者應該已經安裝而不顯示消息。但是,在所有三種情況下,都顯示了該消息,並且安裝被中止。 –

+0

爲了回答你的問題,當我寫下「當我用FileSearch元素的MinVersion屬性省略重新編譯」時,我解釋說第二個日誌文件摘錄是我重新編譯「 「而不是」「用於測試目的。 –

+0

很奇怪。爲我工作沒有任何問題,但不是你。你使用的是什麼版本的Wix? –

1

我不能瑞普你的問題,它爲我工作。你在一個合併模塊中做這個嗎?如果是這樣,ProgramFilesFolder將被模塊化,並且不會解析到您認爲它的目錄,除非您將它排隊。

通常,當涉及到簽名表(文件搜索)時,需要了解的一點是,如果不指定它,則需要考慮語言並且不包含邊界。請參閱:

Signature Table

注意在語言欄所指明的語言在 比較中,也沒有辦法忽略語言。如果要文件 滿足MinVersion字段要求而不考慮語言,則 必須在MinVersion字段中輸入一個小於實際值 的值。例如,如果篩選器的最低版本爲 2.0.2600.1183,請使用2.0.2600.1182查找不匹配語言信息的文件。

+0

不,這不在合併模塊內,盡我所知,我遵循了您引用的指導(甚至在我的源代碼中包含了指向同一MSDN頁面的鏈接)。我期望的最低版本是10.0.9200.16384,我正在測試10.0.9200.16383。 –

+0

我需要一個完整的最小樣本來看你做錯了什麼。我一直在做文件搜索多年,它的工作原理。 –

+0

感謝您的回答和評論。我開始朝你所建議的方向努力 - 一個最小的樣本 - 並找到了問題,但我仍在尋找一種方法來實現我的初衷。我已經用完整的描述更新了這個問題。 –

相關問題