[c#] How to determine if .NET Core is installed

I know that for older versions of .NET, you can determine if a given version is installed by following

https://support.microsoft.com/en-us/kb/318785  

Is there an official method of determining if .NET Core is installed?

(And I don't mean the SDK, I want to check a server without the SDK, to determine if it has DotNetCore.1.0.0-WindowsHosting.exe installed on it)

I can see

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NET Cross-Platform Runtime Environment\.NET Framework 4.6\Win\v1-rc1 

with Version# of 1.0.11123.0 on my windows 7 machine, but I don't see the same stuff on my Windows 10 machine.

This question is related to c# asp.net-core .net-core

The answer is


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.


One of the dummies ways to determine if .NET Core is installed on Windows is:

  • Press Windows + R
  • Type cmd
  • On the command prompt, type dotnet --version

dotnet --version

If the .NET Core is installed, we should not get any error in the above steps.


Run this command

dotnet --list-sdks

enter image description here


Alternatively you can just look inside

C:\Program Files\dotnet\sdk


I work primarily with Windows development machines and servers.

I just wanted to point out (at least for NET.Core 2.0 and above) the only thing needed is to execute dotnet --info in a command prompt to get information about the latest version installed. If .NET Core is installed you will get some response.

On my development machine (Windows 10) the result is as follows. SDK is 2.1.2 and runtime is 2.0.3.

.NET Command Line Tools (2.1.2)

Product Information:
 Version:            2.1.2
 Commit SHA-1 hash:  5695315371

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.2\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

On one of my servers running Windows Server 2016 with Windows Server Hosting pack (no SDK) result is as follows. No SDK, runtime is 2.0.3.

Microsoft .NET Core Shared Framework Host

Version  : 2.0.3
Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

Cheers !


(1) If you are on the Window system.

Open the command prompt.

 dotnet --version

(2) Run the below command If you are on Linux system.

dotnet --version

dotnet --info

You can see which versions of the .NET Core SDK are currently installed with a terminal. Open a terminal and run the following command.

dotnet --list-sdks

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

It's possible that .NET Core is installed but not added to the PATH variable for your operating system or user profile. Running the dotnet commands may not work. As an alternative, you can check that the .NET Core install folders exist.

It's installed to a standard folder if you didn't change it during the instillation

  • dotnet executable C:\program files\dotnet\dotnet.exe

  • .NET SDK C:\program files\dotnet\sdk\{version}\

  • .NET Runtime C:\program files\dotnet\shared\{runtime-type}\{version}\

For more details check How to check that .NET Core is already installed page at .NET documentation


The following commands are available with .NET Core SDK 2.1 (v2.1.300):

To list all installed .NET Core SDKs use: dotnet --list-sdks

To list all installed .NET Core runtimes use dotnet --list-runtimes

(tested on Windows as of writing, 03 Jun 2018, and again on 23 Aug 2018)

Update as of 24 Oct 2018: Better option is probably now dotnet --info in a terminal or PowerShell window as already mentioned in other answers.


Look in C:\Program Files\dotnet\shared\Microsoft.NETCore.App to see which versions of the runtime have directories there. Source.

A lot of the answers here confuse the SDK with the Runtime, which are different.


On windows, You only need to open the command prompt and type:

dotnet --version

If the .net core framework installed you will get current installed version

see screenshot:

enter image description here


It doesn't need a installation process.

I have pinned "VSCore" on my taskbar (win10), so open it, and open a task manager choose "Visual Studio Core" process expand left arrow and over any of them child process right button over it and click in "Open File Location" menu.

If you don't remember where is installed search "Code.exe" file in all your hard drives.


dotnet --info

OR

dotnet --version

write the above command(s) on your CMD or Terminal. Then it will show something like bellow enter image description here

Or

enter image description here


After all the other answers, this might prove useful.

Open your application in Visual Studio. In Solutions Explorer, right click your project. Click Properties. Click Application. Under "Target Framework" click the dropdown button and there you are, all of the installed frameworks.

BTW - you may now choose which framework you want.


You can check if dotnet.exe is available:

where dotnet

You can then check the version:

dotnet --version

UPDATE: There is now a better way of doing this, which is well explained in many other answers:

dotnet --info


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. :)


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to asp.net-core

dotnet ef not found in .NET Core 3 How to use Bootstrap 4 in ASP.NET Core ASP.NET Core - Swashbuckle not creating swagger.json file Getting value from appsettings.json in .net core .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Automatically set appsettings.json for dev and release environments in asp.net core? Get ConnectionString from appsettings.json instead of being hardcoded in .NET Core 2.0 App Unable to create migrations after upgrading to ASP.NET Core 2.0 EF Core add-migration Build Failed ASP.NET Core form POST results in a HTTP 415 Unsupported Media Type response

Examples related to .net-core

dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Assets file project.assets.json not found. Run a NuGet package restore Is ConfigurationManager.AppSettings available in .NET Core 2.0? How to update record using Entity Framework Core? Using app.config in .Net Core EF Core add-migration Build Failed Build .NET Core console application to output an EXE What is the difference between .NET Core and .NET Standard Class Library project types? Where is NuGet.Config file located in Visual Studio project?