5

我正在尝试创建一个在我的MSI安装程序之前安装 .NET Framework 4.0 的 WiX 包。我使用命令行参数检查了我的引导程序的日志文件\l log.txt,发现ExePackage::DetectCondition总是评估为假。

我将WixNetFxExtension.dll作为参考包含在我的 Visual Studio 2010 Windows Installer XML Bootstrapper 项目中。

我包括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 Framework 4.0 ( NET40) 定义 ExePackage:

  <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"总是评估为假。即使设置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 Full 并且可以在我的注册表中手动找到 .NET 4.0 条目,无论是在通常的位置还是在下面HKLM\SOFTWARE\Wow6432Node(我在 64 位系统上)。

我错过了什么吗?为什么 DetectCondition 对我不起作用?该项目可以编译、运行、部署有效载荷,否则工作正常。

4

2 回答 2

7

<PropertyRef Id="NETFRAMEWORK40FULL" />是对 MSI 属性的引用,但您正在创建一个包。Bundle 具有与 MSI 属性不同的变量,尽管 Burn 本身提供了许多模仿 MSI 提供的变量的 bundle 变量。

也就是说,WixNetFxExtension 为 4.0 NetFx 安装程序提供包组。你可以用一个简单的<PackageGroupRef Id="NetFx40Redist" />.

于 2013-02-14T04:56:10.193 回答
3

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>
于 2014-05-05T09:57:34.943 回答