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,400 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,125 questions
0 comments No comments
{count} vote

6 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,846 Reputation points
    2022-07-05T16:21:42.353+00:00

    for the installed .net 6 to work with your code, it must be in path. so you could just execute

    dotnet --list-runtimes

    and check the results. you could also just deploy self contained applications and not require an install.