What's the difference between SDK and Runtime in .NET Core?
Asked Answered
G

12

165

I've read many articles, including this one, yet I can't still figure out what's the difference, and they have not explained it either in simple terms or at all.

Can someone please clarify what's the difference between .NET SDK and .NET Runtime?

Update: Using comparisons would be very appreciated. Analogy alongside simple English is highly educational.

Goodkin answered 9/12, 2017 at 20:45 Comment(1)
The SDK is to build the App. The Runtime is to run the App.Yachting
C
93

According to the .Net Core Guide, .NET Core is composed of the following items

  • A .NET runtime, which provides a type system, assembly loading, a garbage collector, native interop and other basic services.
  • A set of framework libraries, which provide primitive data types, app composition types and fundamental utilities.
  • A set of SDK tools and language compilers that enable the base developer experience, available in the .NET Core SDK.
  • The 'dotnet' app host, which is used to launch .NET Core apps. It selects the runtime and hosts the runtime, provides an assembly loading policy and launches the app. The same host is also used to launch SDK tools in much the same way.

The SDK is all of the stuff that is needed/makes developing a .NET Core application easier, such as the CLI and a compiler.

The runtime is the "virtual machine" that hosts/runs the application and abstracts all the interaction with the base operating system.

Only the latter is required to run the application, but the former is needed to develop the application.

Collings answered 6/4, 2018 at 23:8 Comment(5)
Does it mean that the user have to install both (SDK + Runtime) to develop application or it means the SDK is required only because it contains runtime also?Coucal
@Coucal I just downloaded the SDK installer and it contained also Core Runtime and Asp.Net Core Runtime.Enfeoff
That makes no sense to me. The CLI is invoked to execute a 'framework dependent' executable e.g. dotnet myapp.dll if the cli is required to run an app how on earth can it not be part of the runtime?Walling
This also doesn't answer whether the core libraries are part of the runtime or the SDK.Walling
Runtime is also included in the SDKGula
I
78

Runtime: to run apps

SDK (Runtime + Tooling): to build and run apps

Insalubrious answered 29/11, 2018 at 17:29 Comment(4)
I have a question, Before running my app from Visual Studio, it needs to be built right? Then I always will need an SDK rather than just runtime.Denier
Compiled languages need to be built first. No matter what IDE you use, the SDK is required to build the source code into an application.Insalubrious
Is the Runtime really a part of the SDK or the Runtime just packaged with the SDK as part of the SDK installer?Ja
In this context, what's "apps"?Jarvey
L
65

I'm not inventing anything here. Just copy-pasting the definitions from https://dotnet.microsoft.com/download

enter image description here

The software development kit (SDK) includes everything you need to build and run .NET Core applications, using command-line tools and any editor (like Visual Studio).

The runtime includes everything you need to run .NET Core applications. The runtime is also included in the SDK.

Lunisolar answered 15/8, 2018 at 4:19 Comment(0)
D
15

Sharing from Rick Strahl's post: Which .NET Core Runtime Download do you need?

Only the .NET Core Runtime is required to run an application and provides information about the install.

To develop, build and publish an application will require an SDK.

dotnet.exe installs with a runtime install, but it only provides core features to provide info to run an application and provide info about the install: dotnet mydll.dll and dotnet --info. To build, publish or do anything else you need to install the SDK.

Running the following command will provide information about the install:

dotnet --info

If the command fails it means you do not have the .NET Core runtime installed or available in the system's PATH.

Below is a sample output of the command.

$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.101
 Commit:    236713b0b7

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.2.101/

Host (useful for support):
  Version: 2.2.0
  Commit:  1249f08fed

.NET Core SDKs installed:
  2.1.4 [/usr/local/share/dotnet/sdk]
  2.1.302 [/usr/local/share/dotnet/sdk]
  2.2.101 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

The output tells you:

  • The installed SDK version
  • The active runtime version that's running this dotnet command
  • A list of all installed runtimes and SDKs

Installing an SDK also installs the runtime.


macOS homebrew specific

Installing the homebrew-cask dotnet will conflict with the dotnet-sdk, so to get both the runtime, and the sdk install dotnet-sdk

brew cask install dotnet-sdk

In short, the runtime will allow your OS to run compiled C-Sharp, C# programs, and the sdk will allow you to compile programs written in C-Sharp, C#.


It's important to understand that you can have multiple runtimes and multiple SDKs installed and each project can use a different one. The runtime is determined by your project's runtime specifier in the .csproj file:

<TargetFramework>netcoreapp2.1</TargetFramework>

The SDK is either the last globally installed SDK which is the default, or you can explicitly override the SDK in a global.json placed in the solution root folder. The following explicitly forces my project to use the last RC SDK, instead of the RTM version:

{
 "sdk": {
   "version": "2.1.300-rc.31211"
 }
}

Generally, there should be no need to use a specific lower SDK version as the SDK is backwards compatible and can compile various versions of .NET Core applicatino back to v1.0. IOW, it's OK to use the latest SDK in almost all cases.

.NET Core Runtimes

The .NET Core Runtimes are the smallest self-contained and specific component and contain the absolute minimum to run just .NET Core on a specific platform.

Note it a runtime install does not include the ASP.NET Core meta package runtime dependencies, so if your application references Microsoft.AspNetCore.App or Microsoft.AspNetCore.All you have to seperately download the ASP.NET Core package. However, if you explicitly reference all ASP.NET Core Nuget packages rather than using the meta packages, those packages are deployed as part of your application and it can run with just the runtime.

Essentially you are trading installation package size vs. a runtime pre-install requirement.

References:

Dade answered 13/1, 2019 at 10:45 Comment(2)
Why is Microsoft.AspNetCore.App listed under runtimes? I thought CLR would be a runtime?Mural
@Robotron You're right. Only the shared/Microsoft.NETCore.App/<runtime version> are the runtimes. The shared/Microsoft.AspNetCore.{App,All}/<aspnetcore version> contains the ASP.NET Core libraries. learn.microsoft.com/en-us/dotnet/core/build/…Dade
B
6

SDK ==> to build and run .NET apps

Runtime ==> to run .NET apps

Easy! :)

Baccarat answered 21/10, 2022 at 18:53 Comment(0)
P
3

The SDK is all of the stuff that is needed/makes developing a .NET Core application easier, such as the CLI and a compiler.

The runtime is the "virtual machine" that hosts/runs the application and abstracts all the interaction with the base operating system.

Percept answered 28/11, 2018 at 7:35 Comment(0)
R
2

enter image description here

As summary: If you install SDK, you will have everything you need for development and running the app.

Ransack answered 27/12, 2018 at 2:17 Comment(0)
S
1

adding to stormwild's answer in case you have only the .Net Core Runtime installed you will receive the following output from dotnet --info

>PS C:\Users\Administrator> dotnet --info
>
>Host (useful for support):
>  Version: 2.2.3
>  Commit:  6b8ad509b6 
>
>.NET Core SDKs installed:
>  No SDKs were found.
>
>.NET Core runtimes installed:
>  Microsoft.NETCore.App 2.2.3 [C:\Program 
>Files\dotnet\shared\Microsoft.NETCore.App]
Soapstone answered 26/3, 2019 at 10:47 Comment(0)
R
1

Runtime is enough if we want to run just application on hardware, otherwise to develop and run we need SDK (which includes runtime and tooling).enter image description here

Roderic answered 4/6, 2020 at 11:50 Comment(0)
A
0

The SDK usually includes documentation and other help files. The runtime contains only the binary files for the installation.

Aquavit answered 9/1, 2018 at 17:33 Comment(2)
are you sure? it installs much more than that.Terraqueous
SDK contains the tools that help in developing a .net core app, such as compilers. Runtime hosts a .net core application and handles all the interactions with the underlying OS.Psi
S
0

When you install SDK you also get runtime in that. Check this below, this is what gets installed when we install SDK.

The following were installed at C:\Program Files\dotnet • .NET Core SDK 2.2.100 • .NET Core Runtime 2.2.0 • ASP.NET Core Runtime 2.2.0

Shaunshauna answered 5/12, 2018 at 22:14 Comment(0)
S
0

SDK is required to compile source code and generate bytecode/Intermediate Language Instruction for a specific target OS/runtime. SDK is not tightly coupled to target OS. For ex - SDK installed on Windows can generate bytecode for Linux.

dotnet build --runtime ubuntu.18.04-x64

Runtime is required to run bytecode on a specific OS. Runtime is specific to OS. Runtime for Ubuntu is different than Windows.

Runtime is what makes .Net Core special. Runtime allows .Net apps to be "Write Once, Run Anywhere" similar to Java.

Seabee answered 10/3, 2022 at 2:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.