Difference between .NET Core Runtime and SDK

πŸ’‘ Concept Name

Runtime vs SDK in .NET Core

πŸ“˜ Quick Intro

The .NET Core **Runtime** is needed to run apps, while the **SDK (Software Development Kit)** includes everything required to build and run applicationsβ€”like the CLI, compilers, and libraries.

🧠 Analogy / Short Story

Think of the Runtime as a car engine that can **run** the car, while the SDK is like a full garage with **tools and parts** to build or modify the car. If you just want to drive, you only need the engine (runtime); to build or repair cars, you need the garage (SDK).

πŸ”§ Technical Explanation

  • Runtime: Includes only the libraries and components needed to **run** an app.
  • SDK: Includes compilers (`csc`, `msbuild`), CLI tools, and the runtime itself.
  • dotnet run needs SDK, but dotnet yourApp.dll needs just Runtime.
  • Runtime is lightweight and meant for **deployment**, SDK is for **development**.

🎯 Purpose & Use Case

  • βœ… Install SDK on developer machines to **create, compile, and test** code
  • βœ… Install only Runtime on production servers to **run deployed apps**
  • βœ… Helps minimize footprint and enhance performance during deployment

πŸ’» Real Code Example

# On dev machine
dotnet new console
dotnet build
dotnet run

# On server (with runtime only)
dotnet MyApp.dll

❓ Interview Q&A

Q1: What is .NET Core Runtime?
A: A set of libraries and components required to run an application.

Q2: What is .NET Core SDK?
A: A development package that includes runtime + compilers + tools.

Q3: Do we need SDK to run apps?
A: No, Runtime is sufficient to run published apps.

Q4: Which one includes `dotnet new` and `dotnet build`?
A: The SDK.

Q5: Is SDK heavier than Runtime?
A: Yes, SDK includes more components for development.

Q6: Which should be installed on CI/CD pipelines?
A: SDK for build agents, Runtime for deployment machines.

Q7: Can SDK be used to run apps?
A: Yes, it includes runtime as well.

Q8: Is Runtime version-specific?
A: Yes, you must match the Runtime version your app targets.

Q9: How to check installed SDKs?
A: Run `dotnet --list-sdks` in the terminal.

Q10: Why separate SDK and Runtime?
A: To optimize deployment and reduce size on production environments.

πŸ“ MCQs

Q1. Which of these is used to build .NET Core applications?

  • Runtime
  • CLI
  • JRE
  • SDK

Q2. Which tool does `dotnet build` require?

  • Runtime
  • MSIL
  • SDK
  • JDK

Q3. What does the .NET Core Runtime contain?

  • All dev tools
  • Only the components needed to run the app
  • IDE support
  • Compiler and debugger

Q4. Which one is lighter in size?

  • SDK
  • Runtime
  • Both are equal
  • Depends on OS

Q5. If you install SDK, do you get Runtime?

  • No
  • Yes
  • Only partially
  • Only in Visual Studio

Q6. Which command lists installed SDKs?

  • dotnet check
  • dotnet --version
  • dotnet list
  • dotnet --list-sdks

Q7. Which should be installed on production servers?

  • SDK
  • Runtime
  • Visual Studio
  • CLI only

Q8. Is SDK version always same as Runtime?

  • Yes
  • Not necessarily
  • Always yes
  • No relation

Q9. What is the purpose of SDK?

  • Only to run apps
  • To test in browser
  • To develop, compile, and build applications
  • To manage memory

Q10. Which tool allows you to use `dotnet new`?

  • Runtime
  • Compiler
  • NuGet
  • SDK

πŸ’‘ Bonus Insight

Always install the **latest SDK** for development to ensure compatibility with new templates and APIs, but only deploy the Runtime version you’ve published against to reduce security surface and size.

πŸ“„ PDF Download

Need a handy summary for your notes? Download this topic as a PDF!

πŸ’¬ Feedback
πŸš€ Start Learning
Share:

Tags: