421

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.

Pac0
  • 21,465
  • 8
  • 65
  • 74
weloytty
  • 5,808
  • 5
  • 28
  • 35
  • 4
    Good question. Anyone following .NET Core knows that the Runtime and SDK versioning is a very confusing topic. – Sean Feb 18 '17 at 00:10
  • 1
    @Chiramisu, All of the checked ones below worked for me, but because of some irrelevant implementation details, I went with Desired State Configuration, and used that to ensure that dnc windows server hosting is installed. (I.e I have Ensure=Absent on DotNetCore.1.0.0-WindowsServerHosting.exe and Ensure=Present on DotnetCore.2.0.5-WindowsServerHosting.exe) (or any other filename you can find want). DSC handles all of the mess involved with checking to make sure the appropriate package is installed/uninstalled. – weloytty Mar 23 '18 at 11:23
  • 3
    dotnet --list-sdks and dotnet --list-runtimes are available on my host with 2.1.300-preview1-008174 as the active version – jumpercake May 10 '18 at 19:06
  • 2
    Run This below command in powershell dotnet --info [Source](https://stackoverflow.com/questions/38567353/how-to-determine-if-net-core-is-installed/46858284#46858284) – manikanta kumar Apr 26 '19 at 06:17

21 Answers21

505

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.

InteXX
  • 6,135
  • 6
  • 43
  • 80
Sean
  • 8,407
  • 3
  • 31
  • 33
  • 16
    On macOS: `ls /usr/local/share/dotnet/shared/Microsoft.NETCore.App/` – Sergii Volchkov Jun 11 '17 at 19:02
  • In my case, dotnet --version said 1.1.0, but the installed versions included 1.1.2. Just for checking, I renamed dotnet.exe, and dotnet --version didn't find any version. I then reinstalled 1.1.2, and dotnet --version again said I had 1.1.0. – William Jockusch Aug 17 '17 at 15:45
  • 1
    @SergiiVolchkov thanks for comment. Can you please tell me how to uninstall dotnet core1.0.0 from mac? – Pankaj Parkar Sep 02 '17 at 17:15
  • 1
    .NET Core 2.1.0 adds "dotnet --list-runtimes" and "dotnet --list-sdks" – b8adamson Mar 02 '18 at 15:27
  • 3
    `dotnet --version` lists the SDK in use, which is the latest by default, but not always true. If you have a global.json file in your folder structure, it will display whatever version is set in global.json, not the latest. – Maíra Wenzel - MSFT Mar 27 '18 at 01:29
  • Running `dotnet` does *not* show version information, at least as of 2.0 with a runtime-only install. – jaycer Oct 23 '18 at 16:51
  • @Sean according to the [official documentation](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet?tabs=netcore1x), `dotnet --info` has always existed. ;) – Chiramisu Nov 07 '18 at 16:48
  • @Chiramisu - I updated the sentence to be more accurate. Thanks. – Sean Nov 14 '18 at 03:18
  • 1
    for noobs - these need to be run on windows cmd line – Prashanth Subramanian Nov 12 '20 at 08:22
229

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
InteXX
  • 6,135
  • 6
  • 43
  • 80
Andriy Tolstoy
  • 5,690
  • 2
  • 31
  • 30
  • 1
    @MarceloFilho Which version do you have? You can get it using ```[System.Environment]::OSVersion```. I tested above-mentioned commands using Windows 10 Version 10.0.15063.0. It works fine. – Andriy Tolstoy Mar 02 '18 at 08:06
  • 8
    I can confirm this works perfectly on Windows server 2016 and windows 10. – user5389726598465 May 01 '18 at 09:58
  • 2
    Isn't dotnet command available only with the SDK installed? Which was exactly opposite of what the OP asked. – Aurimas Stands with Ukraine Jun 05 '18 at 07:32
  • @AurimasN. No, the dotnet.exe command is available with both the SDK and Runtime deployments. The SDK simply adds the necessary CLI commands, and prerequisite libraries, necessary to perform "dotnet.exe build" and "dotnet.exe run" from within a project. – Jason Mock Aug 16 '18 at 23:31
  • 3
    Works in PowerShell on Windows 10 but I prefer `dotnet --info` suggested in other answers. – Manfred Oct 24 '18 at 02:20
  • even though this works the next answer is the best because it's the one actually supported by the CLI – Ricardo Rodrigues Nov 09 '18 at 08:29
184

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

Chiramisu
  • 4,687
  • 7
  • 47
  • 77
  • 14
    What's incredible is this is the actual answer. And it's buried underneath a stack of answers from people that didn't even bother to read the question correctly. – Jammer Apr 12 '18 at 08:53
  • 2
    `--info` doesn't work on my server, whereas `--version` does work. The info option gives me: `Did you mean to run dotnet SDK commands? Please install dotnet SDK from: http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409` – ArieKanarie Jun 04 '18 at 13:29
  • @ArieKanarie You might need to repair using the [Microsoft .NET Framework Repair Tool](https://support.microsoft.com/en-us/help/2698555/microsoft-net-framework-repair-tool-is-available). – Chiramisu Jun 04 '18 at 18:44
123

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

Robert Paulsen
  • 4,935
  • 3
  • 21
  • 27
  • 36
    It outpus dotnet CLI version, not runtime.. It's two different things. Having CLI installed, doesn't mean runtime is installed and if it's same version. – Aleksanderis Mar 10 '17 at 16:31
  • `ssh`ed to a server with only the runtime installed to confirm, it doesn't work. [See this answer instead](https://stackoverflow.com/a/46858284/1678053). – galdin Dec 02 '17 at 05:50
53

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.

Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219
  • 7
    See [comment above](https://stackoverflow.com/questions/38567353/how-to-determine-if-netcore-is-installed) to the same answer: It outpus dotnet CLI version, not runtime.. It's two different things. Having CLI installed, doesn't mean runtime is installed and if it's same version – Michael Freidgeim Sep 13 '17 at 03:58
  • 1
    Nitpcking, but you can't have a CLI that works without a runtime installed. So if you have a CLI, you will have *some* runtime, it's just that it may be a completely different version. – omajid Dec 13 '17 at 23:06
  • @omajid Not sure what CLI you're talking about. The CLI I'm referring to in my answer is the default command prompt CLI on Windows 10 x64 which is installed/available without special installations – Zameer Ansari Dec 14 '17 at 05:58
  • This isn't the answer to the question. – Jammer Apr 12 '18 at 08:55
  • @Jammer I suggest you provide an [edit](https://stackoverflow.com/posts/40100462/edit) suggestion – Zameer Ansari Apr 12 '18 at 11:46
  • According to other answers `dotnet --version` only works if **SDK** for .NET Core is installed. The question asks for a solution that will work even if **only the runtime** for .NET Core is present. – ToolmakerSteve Mar 14 '19 at 13:51
  • @ZameerAnsari - Why do I get ASP.NET Core in the runtime list? ASP.NET Core should be part of SDK, not the runtime. As per my understanding, the runtime only needs to run MSIL code on the native platform. So, involvement of ASP.NET with runtime is creating confusion. – Ankush Jain May 22 '21 at 20:33
  • @AnkushJain I'm sorry because it's difficult to say why - it's been a very long time since I have worked on .NET :( – Zameer Ansari May 23 '21 at 10:47
21

(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
JohnLBevan
  • 22,735
  • 13
  • 96
  • 178
Hiren Parghi
  • 1,795
  • 1
  • 21
  • 30
  • `type dotnet --version` - Doesn't work on windows 10. `dotnet --version` works though. You sure about your answer or was that `type` a typo? Both the linux commands work on Win 10 for me. – Aditya Feb 05 '18 at 18:14
  • @Aditya agree think the `type` is an instruction to the reader rather than part of the command. I've edited the post to match. – JohnLBevan Apr 02 '18 at 09:25
  • Yes, it was an instruction. – Hiren Parghi Apr 19 '18 at 11:09
16

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 !

Hakan Çelik Mk1
  • 419
  • 4
  • 11
13

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.

Manfred
  • 5,320
  • 3
  • 35
  • 29
  • We all can learn. Curious to know the reason for the downvote. Perhaps leave a comment when you downvote? – Manfred Aug 22 '18 at 20:25
  • I didn't downvote, but I speculate it may be because you mentioned commands "available with .NET Core SDK", whereas question states "I want to check a server without the SDK". Your answer would be improved if you determine which of the above commands work when *only runtime* is installed. – ToolmakerSteve Mar 14 '19 at 13:48
  • @ToolmakerSteve Yes, that could be the point. I don't have an environment, though, without the SDK and wouldn't want to go to that length removing it.... Thank you for your comment, though. Very much appreciated. – Manfred Mar 17 '19 at 21:58
8

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

Eli Dagan
  • 808
  • 8
  • 14
7

--On CMD

For .Net Framework

wmic product get description | findstr /C:".NET Framework

For .Net Core

dotnet --info
4

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
SOUVIK SAHA
  • 191
  • 2
  • 4
3

Run this command

dotnet --list-sdks

enter image description here

Vivek Bani
  • 3,703
  • 1
  • 9
  • 18
3

I came here looking for a programmatic way to determine this; while this question has many good answers, none of them seem programmatic.

I made a small file in C# that parses the output of dotnet.exe --list-runtimes which could be pretty easily adapted to fit your needs. It uses the CliWrap nuget package; you could probably do without it, but I already used it in my project, as it makes command line handling easier for my needs.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CliWrap;
using CliWrap.EventStream;

// License: Do whatever you want with this. This is what my project uses,
// I make no guarantees it works or will work in the future
// THIS IS ONLY FOR .NET CORE DETECTION (no .NET framework!)
// Requires CliWrap https://github.com/Tyrrrz/CliWrap

namespace DotnetHelper
{
    /// <summary>
    /// Class that can determine if a version of .NET Core is installed
    /// </summary>
    public class DotNetRuntimeVersionDetector
    {
        /// <summary>
        /// This is very windows specific
        /// </summary>
        /// <param name="desktopVersionsOnly">If it needs to filter to Windows Desktop versions only (WPF/Winforms).</param>
        /// <returns>List of versions matching the specified version</returns>
        public static async Task<Version[]> GetInstalledRuntimeVersions(bool desktopVersion)
        {
            // No validation. Make sure exit code is checked in the calling process.
            var cmd = Cli.Wrap(@"dotnet.exe").WithArguments(@"--list-runtimes").WithValidation(CommandResultValidation.None);
            var runtimes = new List<Version>();
            await foreach (var cmdEvent in cmd.ListenAsync())
            {
                switch (cmdEvent)
                {
                    case StartedCommandEvent started:
                        break;
                    case StandardOutputCommandEvent stdOut:
                        if (string.IsNullOrWhiteSpace(stdOut.Text))
                        {
                            continue;
                        }

                        if (stdOut.Text.StartsWith(@"Microsoft.NETCore.App") && !desktopVersion)
                        {
                            runtimes.Add(parseVersion(stdOut.Text));
                        }
                        else if (stdOut.Text.StartsWith(@"Microsoft.WindowsDesktop.App") && desktopVersion)
                        {
                            runtimes.Add(parseVersion(stdOut.Text));
                        }
                        break;
                    case StandardErrorCommandEvent stdErr:
                        break;
                    case ExitedCommandEvent exited:
                        break;
                }
            }

            return runtimes.ToArray();
        }

        private static Version parseVersion(string stdOutText)
        {
            var split = stdOutText.Split(' ');
            return Version.Parse(split[1]); // 0 = SDK name, 1 = version, 2+ = path parts
        }
    }
}
Mgamerz
  • 2,872
  • 2
  • 27
  • 48
2
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

Amar Anondo
  • 662
  • 10
  • 16
2

This method works only on Windows and may be a bit of overkill.

function Get-InstalledApps {
  [CmdletBinding(SupportsShouldProcess=$false)]
  Param ([Parameter(Mandatory=$false, ValueFromPipeline=$true)] [string]$ComputerName=$env:COMPUTERNAME,
         [Parameter(Mandatory=$false, ValueFromPipeline=$false)] [System.Management.Automation.PSCredential]$Credential)

  Begin { Write-Verbose "Entering $($PSCmdlet.MyInvocation.MyCommand.Name)" }

  Process {
    $HKEY_LOCAL_MACHINE=2147483650
    $Results=@()

    if ($Credential -eq $null) { $Reg=[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$ComputerName) }
    else { $Reg=Get-WmiObject -Namespace "root\default" -List "StdRegProv" -ComputerName $ComputerName -Credential $Credential }

    $RegPath=@("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")
    if ([IntPtr]::Size -ne 4) {
      $RegPath+="SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
    }

    for ($i=0; $i -lt $RegPath.Count; $i++) {
      if ($Credential -eq $null) {
        $RegKey=$Reg.OpenSubKey($RegPath[$i])
        $InstallKeys=$RegKey.GetSubKeyNames()
        $RegKey.Close()
      }
      else { $InstallKeys=$Reg.EnumKey($HKEY_LOCAL_MACHINE,$RegPath[$i]) | Select-Object -ExpandProperty sNames }
      $InstallKeys=@($InstallKeys)

      for ($j=0; $j -lt $InstallKeys.Count; $j++) {
        if ($Credential -eq $null) {
          $AppKey=$Reg.OpenSubKey(($RegPath[$i]+"\\"+$InstallKeys[$j]))
          $Result=New-Object -Type PSObject -Property @{ComputerName=$ComputerName;
                                                        DisplayName=$AppKey.GetValue("DisplayName");
                                                        Publisher=$AppKey.GetValue("Publisher");
                                                        InstallDate=$AppKey.GetValue("InstallDate");
                                                        DisplayVersion=$AppKey.GetValue("DisplayVersion");
                                                        UninstallString=$AppKey.GetValue("UninstallString")}
          $AppKey.Close()
        }
        else {
          $Result=New-Object -Type PSObject -Property @{ComputerName=$ComputerName;
                                                        DisplayName=$Reg.GetStringValue($HKEY_LOCAL_MACHINE,($RegPath[$i]+"\"+$InstallKeys[$j]),"DisplayName").sValue;
                                                        Publisher=$Reg.GetStringValue($HKEY_LOCAL_MACHINE,($RegPath[$i]+"\"+$InstallKeys[$j]),"Publisher").sValue;
                                                        InstallDate=$Reg.GetStringValue($HKEY_LOCAL_MACHINE,($RegPath[$i]+"\"+$InstallKeys[$j]),"InstallDate").sValue;
                                                        DisplayVersion=$Reg.GetStringValue($HKEY_LOCAL_MACHINE,($RegPath[$i]+"\"+$InstallKeys[$j]),"DisplayVersion").sValue;
                                                        UninstallString=$Reg.GetStringValue($HKEY_LOCAL_MACHINE,($RegPath[$i]+"\"+$InstallKeys[$j]),"UninstallString").sValue;}
        }
        if ($Result.DisplayName -ne $null) { $Results+=$Result }
      }
    }
    if ($Credential -eq $null ) { $Reg.Close() }
    $Results
  }

  End { Write-Verbose "Exiting $($PSCmdlet.MyInvocation.MyCommand.Name)" }
}

$NetSDK=Get-InstalledApps | Where-Object { $_.DisplayName -like "*.NET Core SDK*" } | Sort-Object -Property DisplayVersion -Descending | Select-Object -First 1
$NetHost=Get-InstalledApps | Where-Object { $_.DisplayName -like "*ASP.NET Core*" } | Sort-Object -Property DisplayVersion -Descending | Select-Object -First 1
$NetSDK
$NetHost
1

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.

jaycer
  • 2,941
  • 2
  • 26
  • 36
1

Alternatively you can just look inside

C:\Program Files\dotnet\sdk

Zeus
  • 3,091
  • 6
  • 47
  • 60
1

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

ElasticCode
  • 7,311
  • 2
  • 34
  • 45
1

On windows I've checked the registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET Core\Shared Framework\v5.0\5.0.12

Simon Stanford
  • 353
  • 3
  • 10
  • Here's another key that seems to be relevant (checked on a machine that only has the runtime installed, not the SDK): `HKEY_LOCAL_MACHINE\SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedhost\Version\6.0.4` – Tawab Wakil Apr 21 '22 at 21:03
0

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.

Baruch Atta
  • 421
  • 1
  • 5
  • 16
0

You can use Run> command > dotnet --version enter image description here

ISK
  • 85
  • 1
  • 9