In this article, we will learn how to check if .NET is already installed on both Windows and Linux.
Some developers find it difficult to understand which components of .NET need to be installed before the development starts. This is often the case with beginners.
Understanding .NET SDK and .NET Runtime
The .NET projects are associated with a software development kit, also known as .NET SDK. Each project SDK is a set of builds with associated tasks that are responsible for compiling, generating binaries, and publishing code.
Usually, there are different SDKs available for each type of project. For example, there are SDKs for Web, Blazor, Windows Desktop, etc.Â
The .NET SDK is the base SDK for .NET and all the others reference it. We could author our own SDK and distribute it via NuGet, for instance.
Along with the SDK, we’ll find another component when installing .NET, the Runtime. The Runtime contains the components needed to run our existing applications.Â
Display .NET SDK Versions on Windows
After installing any supported version on the .NET download page we can easily see which versions of the .NET SDK are installed with a terminal. Make sure to install SDK and runtime prior to running these commands.
Let’s open a terminal and run the command: dotnet --list-sdks
, this way we can list the SDKs installed on our machine:
C:\> dotnet --list-sdks 3.1.415 [C:\Program Files\dotnet\sdk] 3.1.415 [C:\Program Files\dotnet\sdk] 5.0.403 [C:\Program Files\dotnet\sdk] 5.0.403 [C:\Program Files\dotnet\sdk] 6.0.100-preview.7.21379.14 [C:\Program Files\dotnet\sdk] 6.0.100-preview.7.21379.14 [C:\Program Files\dotnet\sdk]
Display .NET Runtime Versions on Windows
After installing any supported runtime version on the .NET download page we can easily see which versions of the .NET Runtime are installed with a terminal.
Let’s open a terminal and run the command dotnet --list-runtimes
, this way we can list the runtimes installed on our machine:
C:\> dotnet --list-runtimes Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-preview.7.21378.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-preview.7.21378.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Check .NET Information on Windows
Usually, when we install .NET on Windows there is a standard folder such as the paths described below:
- Executable
C:\Program Files\dotnet - SDK
C:\Program Files\dotnet\sdk\
- Runtime
C:\Program Files\dotnet\shared
Alternatively, we can run the command dotnet --info
to list both the SDK and runtime versions. This command encapsulates both dotnet --list-sdks
and dotnet --list-runtimes
commands at once:
C:\> dotnet --info .NET SDK (reflecting any global.json): Version: 6.0.100-preview.7.21379.14 Commit: 22d70b47bc Runtime Environment: OS Name: Windows OS Version: 10.0.22523 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\ Host (useful for support): Version: 6.0.0-preview.7.21377.19 Commit: 91ba01788d .NET SDKs installed: ... .NET runtimes installed: ...
Display .NET SDK Versions on Linux
Now, let’s check the installation of the .NET SDK and its runtime on Linux. In this article, we are using Ubuntu 20.04.
Let’s open a terminal and run the dotnet --list-sdks
command:
mrrobot@LAPTOP-F5CNACI3:/mnt$ dotnet --list-sdks 6.0.101 [/usr/share/dotnet/sdk]
As we can see the information is there, but the path is different.
Display .NET Runtime Versions on Linux
We can list which versions of the .NET runtime are installed with the dotnet --list-runtimes
command:
mrrobot@LAPTOP-F5CNACI3:/mnt$ dotnet --list-runtimes Microsoft.AspNetCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Check .NET Information on Linux
Usually, when we install .NET on Linux there is a standard folder such as the paths described below:
- Executable
/home/user/share/dotnet/dotnet - SDK
/home/user/share/dotnet/sdk/{version}/
- Runtime
/home/user/share/dotnet/shared/{runtime-type}/{version}/
Again, we can run the command dotnet --info
to list both the SDK and runtime versions:
mrrobot@LAPTOP:/mnt$ dotnet --info .NET SDK (reflecting any global.json): Version: 6.0.101 Commit: ef49f6213a Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/6.0.101/ Host (useful for support): Version: 6.0.1 Commit: 3a25a7f1cc .NET SDKs installed: ... .NET runtimes installed: ...
Conclusion
In this article, we’ve covered some ways to check if .NET is already installed on both Windows and Linux environments by using the .NET CLI.
Thanks for that article. The topic is pretty overwhelming, when you
get started with dot.net especially as a beginner.
Thanks Elmo. That was our main point when creating this article.
Nice article, simple and straightforward!
Thank you Ramon.