Setup
This section has one goal: set up the .NET development environment and confirm that it works. We’ll verify it by running a small program that prints the .NET version on your machine.
00-setup/Program.cs
cs
using System.Runtime.InteropServices;
Console.WriteLine("Hello, .NET!");
Console.WriteLine($".NET runtime version: {Environment.Version}");
Console.WriteLine($"Operating system: {RuntimeInformation.OSDescription}");If you see output similar to this, you’re done:
text
Hello, .NET!
.NET runtime version:11.0.0
Operating system:Microsoft Windows 10.0.26200Let’s go step by step.
What you need
| Tool | Purpose | Required? |
|---|---|---|
| .NET 11 SDK | All the tools needed to compile and run C# programs | Yes |
| VS Code + C# Dev Kit extension | Editor with completion, error hints, and debugging | Recommended (other editors work too) |
| A terminal | Run dotnet commands | Yes |
| curl | Send HTTP requests from the terminal to verify endpoints | Recommended |
Install the .NET 11 SDK
First, distinguish these two terms:
- SDK (Software Development Kit): for writing programs. It includes the compiler, the
dotnetCLI, and the runtime. - Runtime: only runs already-compiled programs and is typically installed on servers.
For development, installing the SDK is enough; you don’t need to install the runtime separately.
powershell
winget install Microsoft.DotNet.SDK.11bash
brew install --cask dotnet-sdkbash
# Installation varies by distribution. See the official documentation:
# https://learn.microsoft.com/dotnet/core/install/linuxYou can also download an installer from the .NET downloads page.
After installation, open a new terminal so the updated PATH takes effect, then run:
bash
dotnet --versionYou should see a version number beginning with 11.0, for example:
text
11.0.100TIP
If multiple SDK versions are installed, dotnet --list-sdks lists them all. Multiple versions can coexist without interfering with each other.
Why .NET 11?
.NET releases a major version every November. Even-numbered versions are LTS (Long Term Support) and receive three years of official support; odd-numbered versions are STS (Standard Term Support) and receive two years.
.NET 11 is the STS release from November 2026 and is supported through November 2028. It is the latest version, and all code in this tutorial is based on .NET 11 and its included C# 15. If your team requires an LTS release, you can choose .NET 10, which is also supported through November 2028.
WARNING
Many ASP.NET Core tutorials online are based on .NET 5 or earlier and use patterns such as Startup.cs and ConfigureServices. These are older patterns and are no longer needed in .NET 11. Check when an article was published.
Install an editor
We recommend VS Code with Microsoft’s official C# Dev Kit extension:
- Install VS Code.
- Open the Extensions panel (
Ctrl+Shift+X, orCmd+Shift+Xon macOS), search for C# Dev Kit, and install it. It will also install the core C# extension.
Once installed, you’ll get member completion, type information on hover, live compile errors (red squiggles), and one-click debugging. We’ll rely on these features throughout the later chapters. C# is statically typed, so the editor can catch many errors before you run the program.
TIP
Other options work well too: JetBrains Rider is free for personal, non-commercial use and has a full feature set; Windows users can also use Visual Studio 2026. This tutorial uses only the dotnet CLI and does not depend on a particular editor.
Get to know the dotnet CLI
dotnet is the unified entry point for .NET. Use it to create projects, add dependencies, compile, and run programs. These are the commands you’ll use throughout this tutorial:
| Command | Purpose |
|---|---|
dotnet new <template> -o <directory> | Create a project from a template |
dotnet run | Compile and run the project in the current directory |
dotnet watch | Run the project and reload it automatically when code changes |
dotnet build | Compile without running |
dotnet add package <package-name> | Add a NuGet package dependency to the project |
FastAPI comparison
dotnet roughly combines the roles of python, pip, and venv: the project file .csproj is similar to pyproject.toml, and NuGet is similar to PyPI. You don’t need a virtual environment; each project declares its own dependencies in its .csproj file.
Run your first program
Create a project with the console template:
bash
dotnet new console -o HelloDotnet
cd HelloDotnet-o HelloDotnet writes the project to the HelloDotnet directory and uses that name for the project. Open the directory and you’ll see two files:
00-setup/HelloDotnet.csproj
xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net11.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>This is the project file, an XML description of what the project is and how to build it. For now, focus on these three lines:
- Line 5,
TargetFramework: the target framework isnet11.0, which means .NET 11. - Line 6,
ImplicitUsings: enables implicit using directives. Common namespaces such asSystemare imported automatically, so code can useConsolewithout first writingusing System;. - Line 7,
Nullable: enables nullable reference type checks so the compiler can help find potential null-reference errors. We’ll cover this in detail in the next chapter.
The other file is Program.cs. Replace its contents with the code at the top of this page, then run:
bash
dotnet runThe first run compiles the program. After a few seconds, you should see:
text
Hello, .NET!
.NET runtime version:11.0.0
Operating system:Microsoft Windows 10.0.26200The version and operating system vary by machine. As long as the runtime version starts with 11.0, you’re all set.
Technical detail
You may have noticed that Program.cs has no class or Main method; execution starts at the first line. These are called top-level statements: the compiler generates a Main method and places this code inside it. This keeps small programs, including the Web APIs later in this tutorial, concise.
Line 1’s using System.Runtime.InteropServices; must be written manually because the namespace containing RuntimeInformation is not in the default implicit-using list.
Get ready to use curl
Starting in Chapter 02, we’ll use curl to send requests to the endpoints we build. Run curl --version to check whether it is installed. If the terminal can’t find the command, install curl with your system’s package manager.
WARNING
In Windows PowerShell 5.1 (the blue PowerShell that comes with Windows), curl is an alias for Invoke-WebRequest, whose behavior is quite different from real curl. Write curl.exe in commands, or use PowerShell 7, Git Bash, or another shell in Windows Terminal.
After completing Chapter 02, you can read the optional appendix: Development Tools Practice to practice compiler diagnostics and dotnet watch. You don’t need it yet.
Summary
- Development machines need only the .NET 11 SDK, which includes the runtime.
dotnet --versionshould print11.0.x. - .NET 11 is an STS release supported through November 2028. Tutorials using
Startup.csshow an older pattern. - We recommend VS Code + C# Dev Kit. Static typing lets the editor catch errors before you run the program.
dotnet new,dotnet run,dotnet watch, anddotnet add packageare four commands used throughout this tutorial..csprojis the project file.Program.csuses top-level statements that execute from the first line.
Your environment is ready. Next: C# Tour, a quick look at the C# syntax used in this tutorial. If you already know a statically typed language such as Java or TypeScript, you can go straight to First Steps.
