When troubleshooting an application, verifying framework compatibility, or preparing an environment upgrade, identifying the installed .NET version is an essential step. Different .NET releases provide different features and runtime behavior, so confirming the version helps avoid unexpected issues. This tutorial demonstrates how to check .NET version.
1. '--list' options
The quickest method to inspect installed .NET SDKs and runtimes is through the command line.
To display installed SDK versions:
dotnet --list-sdks
Example output:
10.0.107 [/usr/lib/dotnet/sdk]
To display installed runtimes:
dotnet --list-runtimes
Example output:
Microsoft.AspNetCore.App 10.0.7 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.7 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
2. 'Environment.Version' property
Applications can also retrieve the current runtime version programmatically by using the Environment.Version property:
Console.WriteLine(Environment.Version);
Example output:
10.0.7
Leave a Comment
Cancel reply