Discover .NET Framework 4.5.1 Using WiX

I am creating an installer project in my solution using WiX 3.8. As part of this installation, I create some startup conditions, one of which checks to see if Microsoft.NET Framework 4.5.1 is installed.

To do this, I want to use some properties in the WixNetFxExtension library, which seem to work fine for older versions of the .NET framework. There is an example of how to do this at http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/check_for_dotnet.html This does not work for .NET 4.5.1, however, since 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 looks like there is no separate property for .NET. 4.5.1, but it also uses the same NETFRAMEWORK45. As far as I understand, v4.5.1 is an in-place update for v4.5, so it uses the same registry keys (I think). Anyway, in this module they just 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 an error message on the machine, which, as I know, installed the .NET Framework 4.5.1. Therefore, I created such a condition to just see the version number returned from the registry:

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

A message box is displayed here with the following text: # 378758 So, I know that the value in the registry is correct.

So, I'm a little confused why my condition failed. Is there something obvious that I'm missing here, or is there another way to compare this value in a condition element?

Here is a fix that includes a 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> 
+7
installer windows wix
source share
1 answer

You include this # in the comparison, which will not help. Have you tried to include # in your CDATA comparison?

I would suggest that when Microsoft people send code samples to detect framework versions, this cannot be done with a simple RegistrySearch in the MSI file.

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

+4
source share

All Articles