Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX 'Bundle' 'ExePackage' 'DetectCondition' is always false

I am trying to create a WiX bundle that installs the .NET Framework 4.0 before my MSI installer. I inspected the log file for my bootstrapper using the command line argument \l log.txt and discovered that the ExePackage::DetectCondition is always evaluating to false.

I am including WixNetFxExtension.dll as a reference in my Visual Studio 2010 Windows Installer XML Bootstrapper project.

I am including the NetFxExtension namespace:

<?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">

Providing the basic bundle framework:

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

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

I am including the <PropertyRef Id="NETFRAMEWORK40FULL" /> in the fragment and then going on to define the ExePackage for .NET Framework 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>
    ...

I have also checked the Visual Studio build output to confirm that the WixNetFxExtension.dll is referenced correctly:

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

The problem is with the DetectCondition property. No matter what I set it to, it evaluates to false.

Thinking that maybe the NETFRAMEWORK40FULL reference cannot be trusted, I tried using this instead:

<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>

Setting DetectCondition="isInstalled" or DetectCondition="isInstalled = true" always evaluates to false. Even setting DetectCondition="true" always evaluates to false!

Here is a log snippet of what I am talking about, with 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.

Specifically, i052: Condition 'true' evaluates to false. and actually Condition 'NOT NETFRAMEWORK40FULL' evaluates to true. even though I have .NET 4.0 Full installed and can manually find the .NET 4.0 entry in my registry, both in the usual spot and under HKLM\SOFTWARE\Wow6432Node (I am on a 64 bit system).

Am I missing something? Why doesn't DetectCondition work for me? The project compiles, runs, deploys the payload(s) and otherwise works fine.

like image 375
Terrabits Avatar asked Feb 13 '13 21:02

Terrabits


2 Answers

<PropertyRef Id="NETFRAMEWORK40FULL" /> is a reference to an MSI property but you're creating a bundle. Bundles have variables that are distinct from MSI properties, though Burn itself provides a number of bundle variables that mimic those that MSI provides.

That said, WixNetFxExtension provides package groups for the 4.0 NetFx installers. You can replace all that with a simple <PackageGroupRef Id="NetFx40Redist" />.

like image 195
Bob Arnson Avatar answered Nov 06 '22 18:11

Bob Arnson


Variables like NETFRAMEWORK40FULL are MSI variables, you cannot use them in Bundles.

I have successfully embedded the .NET Framework 4.0 Client Version within my bundle. Conditions variables resolved from the Registry.

Notice the syntax "&lt;&lt;" (which translates to <<) in DetectCondition attribute. This page may help 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>
like image 25
Dmitry Pryadkin Avatar answered Nov 06 '22 18:11

Dmitry Pryadkin