Discover .NET 4.5.1 and future compatible versions

The guide in the MSDN article How to Determine Which Versions of the .NET Framework Is Installed. I coded the WiX installer to check the registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Release to determine that .NET 4.5.1 is installed, and use this detection to establish the necessary condition.

The problem that I am facing now is when .NET 4.5.2 is installed, the same key is no longer 378675 or 378758 , but now it is 379893 . .NET 4.5.2 is supposed to be a “highly compatible in-place upgrade,” but the recommended version checking algorithm does not support backward compatibility.

This problem was not found in checks of previous versions; registry keys 2.0, 3.0, and 3.5 are still present, even if a later version is installed. e.g. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Version is still present even if 3.5 is installed.

Thus, earlier the Microsoft version detection method was compatible with the transition, but this no longer applies to version 4.5 / 4.5.1 / 4.5.2. What then should I do? I don’t want to just add 379893 (.NET 4.5.2) to the set of registry values ​​that I check, since this probably will not work if (if) .NET 4.5.3 (or another) is released. Maybe I can check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Version na> = 4.5.51641, but not the recommended approach according to MSDN, and what happens if they release, say, 4.6 that somehow is not backward compatible?

+6
source share
2 answers

To find versions of the .NET Framework by querying the registry in code (.NET Framework 4.5 and later) :

Check the meaning of the Release keyword to determine the installed version. To be compatible with forwarding, you can check a value greater than or equal to the values ​​listed in the table.

This was just below where the MSDN link is in the original question (thanks for closing me down).

In my .wxs file, I have code that works, with an error with a valid message on a too low version of .Net 4.5.

Put the following link and property condition in <Product>:

 <!-- Must have at least .Net 4.5.2 which has release 379893 --> <PropertyRef Id="NETFRAMEWORK45RELEASE"/> <Condition Message="$(var.ProductName) requires .NET Framwork 4.5.2. Please install the .NET Framwork then run this installer again."> Installed OR ( NETFRAMEWORK45RELEASE AND NETFRAMEWORK45RELEASE >= "#379893" ) </Condition> 

With the following snippet declared elsewhere:

 <Fragment> <Property Id="NETFRAMEWORK45RELEASE"> <RegistrySearch Id="NetFramework452Release" Root="HKLM" Key="Software\Microsoft\NET Framework Setup\NDP\v4\Full" Name="Release" Type="raw" /> </Property> </Fragment> 
+1
source

I’m not sure why you’ll worry that the future version will not be backward compatible, they have all been until now, and there is no reason to believe that this will change. You create your installer today, and not when 4.6 is released, so even if you could find it, what would you do? Refuse to install, although it is likely to be compatible? It is impossible to detect, except to make sure that the .net version is installed [at least what you are targeting].

Also, if you are really worried about a future major version that violates compatibility, you can build in the installer for the .net version that you are aiming for, if that happens, how your application will be installed, say, Windows 9 / .net 6 later and those that will not be updated, the installer will install the previous version next to each other, and when several .net versions are installed, the one that matches your application will be used.

-2
source

Source: https://habr.com/ru/post/973695/


All Articles