.NET — How to identify which versions are installed

Chris Smith
3 min readDec 12, 2024

--

Introduction

Identifying the correct versions of installed software can be challenging, especially when dealing with underlying frameworks and libraries, rather than user-facing applications where the version is easily visible on an About page.

I recently faced this challenge myself when trying to determine which versions of .NET, particularly .NET Framework, were installed on my development machine.

After some searching of the web, I found the necessary information and retrieved a list of versions installed on my machine. However, much of this information was buried in linked articles and wasn’t easy to find or understand. Therefore, I’ve extracted the key points and compiled them in this blog.

.NET (formerly .NET Core)

The .NET CLI (command-line interface) is included as part of the .NET SDK and provides thedotnet driver. This driver can be used along with a number of arguments and options to perform actions such as running an application and retrieving information about the installed .NET environment

Detailed below are the commands used to list the installed versions of .NET on the user machine.

Installed .NET runtimes

To list the installed .NET runtimes, use the command:

dotnet --list-runtimes

Listing of the currently installed .NET runtimes
Listing of the currently installed .NET runtimes

Installed .NET SDKs

To list the installed .NET SDKs, use the command:

dotnet --list-sdks

Listing of the currently installed .NET SDKs
Listing of the currently installed .NET SDKs

.NET Framework

Unlike .NET, this doesn’t come with a CLI tool that can be easily used to retrieve the installed version. However, it can be done using several methods including the registry editor, querying via code and querying via PowerShell.

All of these methods are documented at Microsoft Learn: .NET Framework Versions.

Installed .NET Framework

My preference to list the installed .NET Framework version is to use the following PowerShell script:

$release = Get-ItemPropertyValue -LiteralPath 'HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name Release
switch ($release) {
{ $_ -ge 533320 } { $version = '4.8.1 or later'; break }
{ $_ -ge 528040 } { $version = '4.8'; break }
{ $_ -ge 461808 } { $version = '4.7.2'; break }
{ $_ -ge 461308 } { $version = '4.7.1'; break }
{ $_ -ge 460798 } { $version = '4.7'; break }
{ $_ -ge 394802 } { $version = '4.6.2'; break }
{ $_ -ge 394254 } { $version = '4.6.1'; break }
{ $_ -ge 393295 } { $version = '4.6'; break }
{ $_ -ge 379893 } { $version = '4.5.2'; break }
{ $_ -ge 378675 } { $version = '4.5.1'; break }
{ $_ -ge 378389 } { $version = '4.5'; break }
default { $version = $null; break }
}

if ($version) {
Write-Host -Object ".NET Framework Version: $version"
} else {
Write-Host -Object '.NET Framework Version 4.5 or later is not detected.'
}

Running this script within a PowerShell window provides the user with the installed version. In the case below this was .NET Framework 4.8.1 or later:

Listing of the currently installed .NET Framework version
Listing of the currently installed .NET Framework version

Reference Material

Microsoft Learn: dotnet command
Provides detail on the dotnet driver/command along with some common uses including examples of how to incorporate option and argument combinations.

Microsoft Learn: .NET Framework Versions
Provides the information required to determine which versions of the .NET Framework are installed.

Versions of .NET
Provides release details with version history for .NET Core and .NET Framework.

Conclusion

Microsoft documentation can sometimes be overwhelming and lengthy, often missing the direct point. My goal here is to offer a clear and straightforward guide to help you determine which versions of .NET and .NET Framework are installed on your machine.

I hope this blog helps in some way🤝

--

--

Chris Smith
Chris Smith

Written by Chris Smith

Senior Software Engineer at Kainos who is normally found on a golf course or watching football. All views expressed here are my own.

No responses yet