Correct approach to Check for .NET 6 installation

DotNET Fan 191 Reputation points
2022-07-04T14:17:15.643+00:00

we have an windows forms app built through .NET 6 and during the installation we need to check whether .NET 6 is installed or not. The installation is built through NSIS Installer. I see couple of places where the version can be checked.

1) Registry

   For x64 versions HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.WindowsDesktop.App  

  For x86 versions   HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\dotnet\Setup\InstalledVersions\x86\sharedfx\Microsoft.WindowsDesktop.App  

2) .NET installed location - %Programfiles%\dotnet\host\fxr

Are these the right approaches ? Any .NET experts /Microsoft experts can advise on the right approaches?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,374 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,119 questions
0 comments No comments
{count} vote

6 answers

Sort by: Most helpful
  1. DotNET Fan 191 Reputation points
    2022-07-04T18:02:21.483+00:00

    As per the link , this is the registry location HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\<arch>\InstallLocation where we have to search. But i dont see the InstallLocation Key under HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\<arch> . Am i missing something?

    ![217511-image.png]1

    1 person found this answer helpful.
    0 comments No comments

  2. Castorix31 81,721 Reputation points
    2022-07-04T15:01:33.227+00:00
    0 comments No comments

  3. DotNET Fan 191 Reputation points
    2022-07-04T15:33:08.52+00:00

    Thanks Castorix .

    It looks like the NET folders can be changed and in that case we can't rely on the folder path.

    When you install .NET from an installer or script, it's installed to a standard folder. Much of the time the installer or script you're using to install .NET gives you an option to install to a different folder. If you choose to install to a different folder, adjust the start of the folder path.

    Is there any registry path that we can rely similiar to dotnetframework registry path for windows?


  4. abbodi86 3,776 Reputation points
    2022-07-04T18:54:18.823+00:00

    The registry version changes per update

    i have these:

    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.NETCore.App]  
    "3.1.26"=dword:00000001  
      
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.WindowsDesktop.App]  
    "5.0.17"=dword:00000001  
      
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.WindowsDesktop.App]  
    "6.0.6"=dword:00000001  
      
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\dotnet\Setup\InstalledVersions\x64\sharedhost]  
    "Version"="6.0.6"  
    
    0 comments No comments

  5. DotNET Fan 191 Reputation points
    2022-07-05T05:06:00.027+00:00

    Thanks abbodi86 for checking this.
    The question here is , which is the common location where we can check for this? Users will have different types of NET installations and if there is a common place where it can be checked , that would be great to know.

    0 comments No comments