I'm using WiX Toolset 5 and I need to detect the version of .NET installed on a machine. I have code to pull the value out of the registry:
SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedhost
but there's a problem with that registry value. If you've ever had a version of .NET installed, and uninstalled it, it stays the same. For instance, if you've installed .NET 6.0.18 and then .NET 8.0.7 and uninstall .NET 8, the registry value will still be 8.0.7.
Is there a better way to get the currently installed highest version of .NET either through a different registry key, a system command, or WiX?