Comprehensive Guide: Detecting .NET Core Runtime and SDK Installation Status

Nov 13, 2025 · Programming · 16 views · 7.8

Keywords: .NET Core Detection | Runtime Version | SDK Installation | Cross-Platform Verification | Command Line Tools

Abstract: This article provides a detailed examination of various methods to detect .NET Core runtime and SDK installation status across Windows, Linux, and macOS systems. It focuses on the officially recommended dotnet --info command and its related options, while also offering alternative approaches including filesystem inspection and PowerShell scripting. Through practical code examples and path analysis, the guide assists developers in accurately identifying installed .NET Core components in diverse environments, with specialized solutions for server environments with runtime-only installations.

Introduction

Accurately detecting the installation status of runtime and SDK components is a fundamental yet critical task in .NET Core development and deployment. Unlike traditional .NET Framework, .NET Core employs a cross-platform design, requiring detection methods that adapt to multiple operating system environments. This article systematically introduces various detection approaches including officially recommended commands, filesystem inspection, and script automation.

Official Command Line Tool Detection

Microsoft provides comprehensive command-line tools for detecting .NET Core installation status. The dotnet --info command serves as the most thorough detection method, outputting detailed runtime environment information including installed runtime versions, SDK versions, operating system details, and runtime identifiers.

Execution example of this command:

dotnet --info

The command produces output similar to:

.NET SDK (reflecting any global.json):
 Version:   8.0.100
 Commit:    57c82c6d3e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100\

Host (useful for support):
  Version: 8.0.0
  Commit:  5e9b9a6f2a

.NET SDKs installed:
  7.0.404 [C:\Program Files\dotnet\sdk]
  8.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Specialized Version Listing Commands

For scenarios requiring specific information, more focused command options are available. dotnet --list-sdks specifically lists all installed SDK versions:

dotnet --list-sdks

Output example:

7.0.404 [C:\program files\dotnet\sdk]
8.0.100 [C:\program files\dotnet\sdk]

Similarly, the dotnet --list-runtimes command focuses exclusively on runtime version detection:

dotnet --list-runtimes

Output example:

Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Direct Filesystem Inspection

In situations where command-line tools are unavailable (such as server environments with runtime-only installations), direct inspection of filesystem installation directories becomes necessary.

In Windows systems, runtimes are typically installed at:

C:\Program Files\dotnet\shared\Microsoft.NETCore.App

SDKs are installed at:

C:\Program Files\dotnet\sdk

In macOS systems, the corresponding path is:

/usr/local/share/dotnet/shared/Microsoft.NETCore.App/

In Linux systems (such as Ubuntu):

/usr/share/dotnet/shared/Microsoft.NETCore.App/

PowerShell Automated Detection

For scenarios requiring automated detection, PowerShell scripts can be employed. The following scripts dynamically obtain the dotnet path and detect installed runtimes and SDKs:

# Detect runtime versions
(dir (Get-Command dotnet).Path.Replace('dotnet.exe', 'shared\Microsoft.NETCore.App')).Name

# Detect SDK versions
(dir (Get-Command dotnet).Path.Replace('dotnet.exe', 'sdk')).Name

Environment Variables and Path Verification

When command execution fails, it may indicate that .NET Core was not properly added to the system PATH environment variable. In such cases, use where dotnet (Windows) or which dotnet (Linux/macOS) to check the location of the dotnet executable.

Windows example:

where dotnet

If a path is returned, it indicates dotnet is installed but may not have proper environment variable configuration.

Version Compatibility and Considerations

It's important to note that behavior of certain legacy detection commands has changed. For example:

Cross-Platform Consistency

.NET Core's design ensures cross-platform consistency. Whether on Windows, Linux, or macOS, the dotnet --info, dotnet --list-sdks, and dotnet --list-runtimes commands maintain identical behavior and output format across all supported operating systems, providing convenience for multi-platform development.

Conclusion

Multiple methods exist for detecting .NET Core installation status, ranging from simple command-line tools to comprehensive filesystem inspection. For most scenarios, dotnet --info provides the most comprehensive information, while specialized commands and filesystem checks serve specific needs. Developers should select appropriate methods based on specific environments and requirements to ensure accurate identification of .NET Core component installation status.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.