Installing the .NET SDK
Before you write C#, you need the .NET SDK — one free download that gives you the compiler, the runtime and the dotnet command-line tool.
On this page · 5 min · Beginner
On this page
- In simple words
- Learning objectives
- Explanation
- Syntax
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Oct 28, 2026
Related tutorials
In simple words#
Installing the .NET SDK is like buying a full toolbox before starting carpentry. Without it you can read plans (code) but you cannot build anything.
- SDK
- Software Development Kit — compiler + tools to build apps.
- Runtime
- Only what is needed to run apps, not build them.
- dotnet CLI
- The command-line tool: dotnet new, dotnet run, dotnet build.
Learning objectives#
- Install the .NET SDK and check the version
- Create a console project with dotnet new
- Build and run with dotnet run
- Understand the files in a new project
Explanation#
Download the .NET SDK from dot.net (choose the latest LTS version if unsure). The SDK includes the runtime, so you do not need both.
After installing, open a new terminal and run dotnet --version. If you see a version number, everything works.
dotnet new console -n HelloApp creates a folder HelloApp with two important files: Program.cs (your code) and HelloApp.csproj (the project file that says which .NET version to target).
dotnet run builds and runs the project in one step. dotnet build only compiles; the output goes into the bin folder.
For an editor, use Visual Studio (Windows, full IDE), VS Code with the C# Dev Kit extension (any OS, lightweight) or JetBrains Rider.
Syntax#
dotnet --version # check the SDK is installed
dotnet new console -n MyApp # create a project
dotnet run # build + run (inside the project folder)
Code example: From nothing to a running app#
dotnet --version
# 9.0.100
dotnet new console -n HelloApp
cd HelloApp
dotnet run
# Hello, World!
dotnet new list # see all project templates (webapi, mvc, blazor...)
dotnet --version prints the installed SDK version. dotnet new creates HelloApp/Program.cs and HelloApp/HelloApp.csproj. dotnet run compiles the project and prints “Hello, World!”.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- dotnet --version confirms the SDK is on your PATH.
- dotnet new console uses the console-app template; -n sets the project and folder name.
- cd HelloApp moves into the project folder, where the .csproj file lives.
- dotnet run restores packages, compiles and runs Program.cs.
- dotnet new list shows the other templates you will use later: webapi, mvc, blazor, xunit.
Real-world use case#
Every .NET project — a console tool, an ASP.NET Core API or a Blazor site — is created, built, tested and published with the same dotnet CLI. CI pipelines in GitHub Actions and Azure DevOps run exactly these commands.
Common mistakes#
The terminal was opened before installing. Close and reopen it (or restart VS Code) so it picks up the new PATH.
“Couldn’t find a project to run” means there is no .csproj in the current folder. cd into the project folder first.
The runtime can run apps but cannot build them. Developers need the SDK.
Best practices#
- Install the SDK, not just the runtime
- Keep one project per folder
- Use dotnet watch run while learning — it reruns on every save
- Commit the .csproj but ignore bin/ and obj/ in git
Remember this#
SDK = tools to build. Runtime = only to run.
new → run → build: dotnet new, dotnet run, dotnet build.
.csproj is the project file; Program.cs is where code starts.
Practice exercise#
Your task: Create a console app called Greeter, change Program.cs so it prints "Setup complete!", and run it.
Need a hint?
Show solution
dotnet new console -n Greeter
cd Greeter
# edit Program.cs: Console.WriteLine("Setup complete!");
dotnet run
# Setup complete!
Mini quiz#
Which command creates a new console project?
Want more? Practise all C# MCQs · C# interview questions
My notes#
Saved in this browser.