Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect .NET Framework 4.5.1 using WiX

I'm creating an installer project in my solution using WiX 3.8. As part of this install I create some launch conditions, one of which is checking that Microsoft .NET Framework 4.5.1 is installed.

To do this I want to use some of the properties in the WixNetFxExtension lib which seem to work fine for older versions of the .NET framework. There is an example of how to do this on http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/check_for_dotnet.html This doesn't work for .NET 4.5.1 however as there is no NETFRAMEWORK451 property to check.

Looking at the source for the NetFx451.wxs module (http://wix.codeplex.com/SourceControl/latest#src/ext/NetFxExtension/wixlib/NetFx451.wxs) it appears that there is no separate property to use for .NET 4.5.1, but rather it also uses the same NETFRAMEWORK45. As I understand it, v4.5.1 is an in-place upgrade for v4.5, so it uses the same registry keys (I think). Anyway, in that module, they simply check the version number returned from NETFRAMEWORK45 as follows:

DetectCondition="NETFRAMEWORK45 >= $(var.NetFx451MinRelease)"

So I assumed that I could just write a condition like the following:

    <PropertyRef Id="NETFRAMEWORK45" />
    <Condition Message="The .NET Framework 4.5.1 was not found.  Stopping installation.">
       <![CDATA[Installed OR (NETFRAMEWORK45 >= 378675)]]>
    </Condition>

But, this returned the error message on a machine that I know has the .NET Framework 4.5.1 installed. So I created a condition like this so I could just see the version number being returned from the registry:

    <PropertyRef Id="NETFRAMEWORK45" />
    <Condition Message ="[NETFRAMEWORK45]">0</Condition>

This shows a message box with the following text: #378758 So I know that the value in the registry is correct.

So I am a bit confused why my condition failed. Is there something obvious I am missing here, or is there some other way to compare that value in the condition element?

Here is the fix to include the hash symbol as suggested by PhilDW:

    <PropertyRef Id="NETFRAMEWORK45" />
    <Condition Message="The .NET Framework 4.5.1 was not found.  Stopping installation.">
      <![CDATA[Installed OR (NETFRAMEWORK45 >= "#378675")]]>
    </Condition>
like image 596
Avery Avatar asked Feb 25 '14 14:02

Avery


1 Answers

You're including that # in the comparison, that's not going to help. Have you tried including the # in your CDATA comparison?

I would assume that when Microsoft people post code examples to detect framework versions it can't be done with a simple RegistrySearch in an MSI file.

http://blogs.msdn.com/b/astebner/archive/2013/10/17/10457758.aspx

like image 198
PhilDW Avatar answered Sep 28 '22 16:09

PhilDW