How to determine if .NET Core is installed
Using Powershell:
Runtimes:
(dir (Get-Command dotnet).Path.Replace('dotnet.exe', 'shared\Microsoft.NETCore.App')).Name
SDKs:
(dir (Get-Command dotnet).Path.Replace('dotnet.exe', 'sdk')).Name
Great question, and the answer is not a simple one. There is no "show me all .net core versions" command, but there's hope.
EDIT:
I'm not sure when it was added, but the info command now includes this information in its output. It will print out the installed runtimes and SDKs, as well as some other info:
dotnet --info
If you only want to see the SDKs: dotnet --list-sdks
If you only want to see installed runtimes: dotnet --list-runtimes
I'm on Windows, but I'd guess that would work on Mac or Linux as well with a current version.
Also, you can reference the .NET Core Download Archive to help you decipher the SDK versions.
OLDER INFORMATION: Everything below this point is old information, which is less relevant, but may still be useful.
See installed Runtimes:
Open C:\Program Files\dotnet\shared\Microsoft.NETCore.App
in Windows Explorer
See installed SDKs:
Open C:\Program Files\dotnet\sdk
in Windows Explorer
(Source for the locations: A developer's blog)
In addition, you can see the latest Runtime and SDK versions installed by issuing these commands at the command prompt:
dotnet
Latest Runtime version is the first thing listed. DISCLAIMER: This no longer works, but may work for older versions.
dotnet --version
Latest SDK version DISCLAIMER: Apparently the result of this may be affected by any global.json config files.
On macOS you could check .net core version by using below command.
ls /usr/local/share/dotnet/shared/Microsoft.NETCore.App/
On Ubuntu or Alpine:
ls /usr/share/dotnet/shared/Microsoft.NETCore.App/
It will list down the folder with installed version name.
The correct answer for runtime-only environments without the SDK, such as a server with the Windows Hosting package installed, is to run PowerShell with the following command:
dotnet --info
Per the official documentation:
- The
--version
option "Prints out the version of the .NET Core SDK in use." and therefore doesn't work if the SDK is not installed. Whereas... - The
--info
option "Prints out detailed information about the CLI tooling and the environment, such as the current operating system, commit SHA for the version, and other information."
Here's another official article explaining how .NET Core versioning works. :)