2013-02-13 79 views
4

我試圖創建一個在我的MSI安裝程序之前安裝.NET Framework 4.0的WiX包。我使用命令行參數\l log.txt檢查了我的引導程序的日誌文件,並發現ExePackage::DetectCondition總是評估爲false。WiX'Bundle''ExePackage''DetectCondition'始終爲false

我包括WixNetFxExtension.dll作爲我的Visual Studio 2010 Windows安裝程序XML引導程序項目中的參考。

我包括NetFxExtension命名空間:

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" 
    xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" 
    xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension"> 

提供了基本框架捆綁:

<Bundle Name="RSA Bootstrapper" 
     ... 
    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" /> 
     ... 

    <Chain> 
     <PackageGroupRef Id="NET40" /> 
     <PackageGroupRef Id="RSA_Application" /> 
    </Chain> 
    </Bundle> 
    ... 

我包括在片段中的<PropertyRef Id="NETFRAMEWORK40FULL" />,然後去上定義.NET的ExePackage框架4.0(NET40):

<Fragment> 
    <PropertyRef Id="NETFRAMEWORK40FULL" /> 
    <PackageGroup Id="NET40"> 
    <ExePackage SourceFile="dotNetFx40_Full_x86_x64.exe" 
     Compressed="yes" 
     Cache="yes" 
     DetectCondition="NETFRAMEWORK40FULL" 
     InstallCommand="/norestart /passive /showrmui /ACTION=Install" 
     Permanent="yes" 
     InstallCondition="NOT NETFRAMEWORK40FULL" 
     Vital="yes" > 
    <ExitCode Value="0" Behavior="success" /> 
    <ExitCode Value="1641" Behavior="scheduleReboot" /> 
    <ExitCode Value="3010" Behavior="scheduleReboot" /> 
    <ExitCode Behavior="error" /> <!-- Everything else is an error --> 
    </ExePackage> 
    ... 

我還檢查了Visual Studio生成輸出以確認WixNetFxExtension.dll被正確引用:

C:\ Program Files(x86)\ WiX Toolset v3.7 \ bin \ Light.exe ... -ext「C :\ Program Files(x86)\ WiX Toolset v3.7 \ bin \ WixNetFxExtension.dll「

問題出在DetectCondition屬性。無論我設置爲什麼,它的評估結果爲false

想,也許NETFRAMEWORK40FULL引用不能被信任,我試圖用這個代替:

<Fragment> 
    <Variable Name="isInstalled" 
     Type="numeric" 
     Value="0" 
     Persisted="yes" 
     bal:Overridable="yes"/> 
    <util:RegistrySearch Id="FindInstallKey" 
     Root="HKLM" Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" 
     Value="Install" 
     Result="exists" 
     Variable="InstallKeyExists" /> 
    <util:RegistrySearch 
     Root="HKLM" Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" 
     Value="Install" 
     Variable="isInstalled" 
     After="FindInstallKey" 
     Condition="InstallKeyExists = true" 
     Format="raw" /> 
</Fragment> 

設置DetectCondition="isInstalled"DetectCondition="isInstalled = true"總是計算爲false。即使設置DetectCondition="true"總是評估爲假!

下面是我所談論的是一個日誌片斷,與DetectCondition="true"

[16A0:17B4][2013-02-13T13:01:43]i001: Burn v3.7.1224.0, Windows v6.1 (Build 7601: Service Pack 1), path: C:\Users\lalic\Documents\Visual Studio 2010\Projects\RSA Preset\Bootstrapper\bin\Release\Bootstrapper.exe, cmdline: '/l log.txt -burn.unelevated BurnPipe.{33090847-CC78-445B-BAAA-564B840B7E8E} {38F95C6A-EC0F-4402-951B-FABFC5827CB6} 6296' 
[16A0:17B4][2013-02-13T13:01:43]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\lalic\Documents\Visual Studio 2010\Projects\RSA Preset\Bootstrapper\bin\Release\log.txt' 
[16A0:17B4][2013-02-13T13:01:43]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\lalic\Documents\Visual Studio 2010\Projects\RSA Preset\Bootstrapper\bin\Release\Bootstrapper.exe' 
[16A0:17B4][2013-02-13T13:01:43]i052: Condition '((VersionNT = v5.1) AND (ServicePackLevel >= 3)) OR ((VersionNT = v5.2) AND (ServicePackLevel >= 2)) OR ((VersionNT = v6.0) AND (ServicePackLevel >= 1)) OR (VersionNT >= v6.1)' evaluates to true. 
[16A0:17B4][2013-02-13T13:01:43]i000: Setting string variable 'WixBundleName' to value 'RSA Bootstrapper' 
[16A0:17B4][2013-02-13T13:01:43]i100: Detect begin, 2 packages 
[16A0:17B4][2013-02-13T13:01:43]i052: Condition 'true' evaluates to false. 
[16A0:17B4][2013-02-13T13:01:43]i103: Detected related package: {D431417D-F0AC-4CFB-8E25-E27F5B8101D9}, scope: PerMachine, version: 2.1.15.0, language: 0 operation: MajorUpgrade 
[16A0:17B4][2013-02-13T13:01:43]i101: Detected package: dotNetFx40_Full_x86_x64.exe, state: Absent, cached: None 
[16A0:17B4][2013-02-13T13:01:43]i101: Detected package: RSA_Preset.msi, state: Absent, cached: None 
[16A0:17B4][2013-02-13T13:01:43]i199: Detect complete, result: 0x0 
[16A0:17B4][2013-02-13T13:02:04]i200: Plan begin, 2 packages, action: Install 
[16A0:17B4][2013-02-13T13:02:04]i052: Condition 'NOT NETFRAMEWORK40FULL' evaluates to true. 

具體來說, i052: Condition 'true' evaluates to false. 實際上Condition 'NOT NETFRAMEWORK40FULL' evaluates to true.即使我有.NET 4.0完全安裝,可以手動查找.NET 4.0在我的註冊表中進入,在通常的位置和HKLM\SOFTWARE\Wow6432Node(我在64位系統上)。

我錯過了什麼嗎?爲什麼不DetectCondition爲我工作?該項目編譯,運行,部署有效負載並以其他方式正常工作。

+0

道歉爲長期職位。試圖徹底!在那張紙上,我使用的是WiX v3.7 – Terrabits 2013-02-13 21:55:36

回答

6

<PropertyRef Id="NETFRAMEWORK40FULL" />是對MSI屬性的引用,但您正在創建一個包。雖然Burn本身提供了許多模仿MSI提供的bundle變量,但bundle具有與MSI屬性不同的變量。

也就是說,WixNetFxExtension爲4.0 NetFx安裝程序提供軟件包組。您可以用簡單的<PackageGroupRef Id="NetFx40Redist" />替換所有這些。

+0

呵呵。我沒有意識到'NETFRAMEWORK40FULL'是一個MSI屬性。謝謝。也許這是導致邏輯錯誤?儘管'NetFx40Redist'完全避免了這個問題,但還是沒有想出那部分。對此有何想法? 我避開使用'',因爲我想控制包的安裝屬性。我決定不再固執並給予一次機會(根據你的建議),到目前爲止,它正在爲我工​​作;我想默認設置是好的。 感謝您的幫助:-) – Terrabits 2013-02-15 03:39:02

+0

是的,您不能在刻錄表達式中使用MSI屬性。這需要一個Burn變量。 – 2013-02-15 17:19:25

+0

「捆綁」變量不能在MSI中使用的事實是毫無意義的。爲什麼甚至有他們? – Brandon 2015-11-02 15:05:48

2

像NETFRAMEWORK40FULL這樣的變量是MSI變量,你不能在Bundles中使用它們。

我已經成功嵌入了。NET Framework 4.0客戶端版本在我的包中。條件變量從註冊表中解析。

請注意DetectCondition屬性中的語法"&lt;&lt;"(其轉換爲< <)。此頁面可能會有幫助http://wix.tramontana.co.hu/tutorial/com-expression-syntax-miscellanea/expression-syntax

<?xml version="1.0" encoding="UTF-8"?> 
<Wix 
    xmlns="http://schemas.microsoft.com/wix/2006/wi" 
    xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" 
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" 
    xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension"> 

    <Bundle 
     Name="My Program Name" 
     Version="1.2.0" 
     Manufacturer="SUSU" 
     UpgradeCode="some-guid"> 

     <Chain> 
      <PackageGroupRef Id="Netfx4"/> 
      <MsiPackage Id="MyProgramInstaller" SourceFile="product.msi" Compressed="yes"/> 
     </Chain> 

     <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense"> 
      <bal:WixStandardBootstrapperApplication 
       LicenseFile="license.rtf" 
       ShowVersion="yes" 
      /> 
     </BootstrapperApplicationRef> 
    </Bundle> 

    <Fragment> 

     <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Client" Value="Version" 
      Variable="Netfx4ClientVersion" /> 

     <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Client" Value="Version" 
      Variable="Netfx4x64ClientVersion" Win64="yes" /> 

     <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" 
      Variable="Netfx4FullVersion" /> 

     <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" 
      Variable="Netfx4x64FullVersion" Win64="yes"/> 


     <PackageGroup Id="Netfx4"> 
      <ExePackage 
       Id="Netfx4" 
       Cache="no" 
       Compressed="yes" 
       PerMachine="yes" 
       Permanent="yes" 
       Vital="yes" 
       SourceFile="c:\Downloads\dotNetFx40_Client_x86_x64.exe" 
       InstallCommand="/q" 
       DetectCondition="(Netfx4FullVersion &lt;&lt; &quot;4&quot;) OR (Netfx4ClientVersion &lt;&lt; &quot;4&quot;) OR (Netfx4x64ClientVersion &lt;&lt; &quot;4&quot;) OR (Netfx4x64FullVersion &lt;&lt; &quot;4&quot;)" 
       /> 
     </PackageGroup> 

    </Fragment> 


</Wix> 
+1

如果要檢測4.5以上版本,則需要使用「Release」值(而不是「Version」),因爲它是數字。本頁顯示如何使用它:https://msdn.microsoft.com/en-CA/library/hh925568(v=vs.110).aspx – 2016-04-19 19:20:39

相關問題