[wix-users] Detecting .Net 4.5.2

Schulze, Martin Martin.Schulze at haufe-lexware.com
Wed Jul 19 03:34:47 PDT 2017


Hi all,

so we got a bundle.wxs where we needed to check for .Net 4.0 as a prerequisite. I found the following existing code (I didn't write it and I'm pretty new WiX):

<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">
...
    <Chain>
      <PackageGroupRef Id='NetFx40Client'/>

      <MsiPackage SourceFile="C:\Users\SchulzeMar\projects\ElsterSetups\17.02\lxelster.msi"
             Name="elster\lxelster.msi"
             Cache="yes" ForcePerMachine="yes" Vital="yes" Compressed="no" Visible="no">
      </MsiPackage>

    </Chain>

  </Bundle>

  <Fragment>

    <util:RegistrySearchRef Id="NETFRAMEWORK40CLIENT"/>

    <?define NetFx40EulaLink =  http://go.microsoft.com/fwlink/?LinkID=188993 ?>

    <WixVariable Id="WixMbaPrereqPackageId" Value="NetFx40Client" />
    <WixVariable Id="WixMbaPrereqLicenseUrl" Value="$(var.NetFx40EulaLink)" />

    <PackageGroup Id="NetFx40Client">
      <ExePackage
          InstallCommand="/q /norestart /ChainingPackage "[WixBundleName]""
          UninstallCommand="/uninstall /q /norestart /ChainingPackage "[WixBundleName]""
          PerMachine="yes"
          DetectCondition="NETFRAMEWORK40CLIENT"
          Id="NetFx40Client"
          Vital="yes"
          Permanent="yes"
          Protocol="netfx4"
          Compressed="no"
          Cache="yes"
          SourceFile="\\s-tfs-deploy\DEPLOY\Setup\3third_party\dotnet_4_0\dotNetFx40_Client_x86_x64.exe"
          Name="data\dotnet\dotNetFx40_Client_x86_x64.exe">
      </ExePackage>
    </PackageGroup>
  </Fragment>
...

This did work but I'd like to understand why.
>From what I found out NETFRAMEWORK40CLIENT is a property defined in Wix NetFXExtension (according to http://wixtoolset.org/documentation/manual/v3/customactions/wixnetfxextension.html) so the util:RegistrySearchRef confuses me (our bundle.wxs does ofc not contain a RegistrySearch element with the same name).

Since we now need to check for .Net 4.5.2, I tried to use WIX_IS_NETFRAMEWORK_452_OR_LATER_INSTALLED property from NetFXExtension. But that condition is always false. Even WIX_IS_NETFRAMEWORK_40_OR_LATER_INSTALLED is false, when the above worked. So I'm clearly doing something wrong.

...
<Chain>
      <PackageGroupRef Id='NetFx452'/>

      <MsiPackage SourceFile="C:\Users\SchulzeMar\projects\ElsterSetups\17.02\lxelster.msi"
             Name="elster\lxelster.msi"
             Cache="yes" ForcePerMachine="yes" Vital="yes" Compressed="no" Visible="no">
      </MsiPackage>

    </Chain>

  </Bundle>

  <Fragment>
    <PropertyRef Id="WIX_IS_NETFRAMEWORK_452_OR_LATER_INSTALLED"/>

    <?define NetFx40EulaLink =  http://go.microsoft.com/fwlink/?LinkID=188993 ?>

    <WixVariable Id="WixMbaPrereqPackageId" Value="NetFx452" />
    <WixVariable Id="WixMbaPrereqLicenseUrl" Value="$(var.NetFx40EulaLink)" />

    <PackageGroup Id="NetFx452">
      <ExePackage
          InstallCommand="/q /norestart /ChainingPackage "[WixBundleName]""
          UninstallCommand="/uninstall /q /norestart /ChainingPackage "[WixBundleName]""
          PerMachine="yes"
          DetectCondition="WIX_IS_NETFRAMEWORK_452_OR_LATER_INSTALLED"
          Id="NetFx452"
          Vital="yes"
          Permanent="yes"
          Protocol="netfx4"
          Compressed="no"
          Cache="yes"
          SourceFile="\\s-tfs-deploy\DEPLOY\Setup\3third_party\dotnet_4_0\dotNetFx40_Client_x86_x64.exe"
          Name="data\dotnet\dotNetFx40_Client_x86_x64.exe">
      </ExePackage>
    </PackageGroup>
  </Fragment>
...

So why does the above one work but my approach does not? What's the recommended way to detect .Net 4.5.2?

Thanks, Martin


More information about the wix-users mailing list