Skip to content

Installing .NET SDK — Setup for C# Development on Windows, Linux, macOS

DodaTech Updated 2026-06-28 6 min read

In this tutorial, you will learn about Installing .NET SDK. We cover key concepts, practical examples, and best practices to help you master this topic.

The .NET SDK is the complete toolchain for building C# applications, including the compiler, runtime, CLI tools, and project templates for web, desktop, mobile, and cloud development.

What You'll Learn

You will install the .NET Software Development Kit (SDK) on Windows, Linux, or macOS, set up your editor of choice (VS Code, JetBrains Rider, or Visual Studio), verify your installation with the dotnet CLI, create your first project, and understand the project structure that C# uses for building applications.

Why It Matters

Before you can write and run any C# code, you need a working development environment. The dotnet CLI is your gateway to building, testing, and publishing .NET applications. A properly configured environment saves hours of troubleshooting later and ensures your code compiles and runs correctly across platforms.

Real-World Use

Every professional C# developer uses the dotnet CLI daily. From creating new projects with dotnet new to running tests with dotnet test and deploying with dotnet publish, the CLI is the foundation of the .NET workflow. CI/CD pipelines on GitHub Actions, Azure DevOps, and Jenkins all run dotnet commands to build and test code.

Learning Path

graph LR
    A["01: What is C#"] --> B["02: Installing .NET"]
    B --> C["03: Hello World"]
    C --> D["04: Variables & Types"]
    D --> E["05: Built-in Types"]
    style A fill:#4a90d9,stroke:#2c5f8a,color:#fff
    style B fill:#4a90d9,stroke:#2c5f8a,color:#fff
    style C fill:#4a90d9,stroke:#2c5f8a,color:#fff
    style D fill:#4a90d9,stroke:#2c5f8a,color:#fff
    style E fill:#4a90d9,stroke:#2c5f8a,color:#fff

Installing the .NET SDK

Windows

The recommended installation methods:

  1. Download the installer from dotnet.microsoft.com
  2. Use winget: winget install Microsoft.DotNet.SDK.8
  3. Use Chocolatey: choco install dotnet-8.0-sdk

After installation, open a new terminal and verify:

dotnet --version

Expected output:

8.0.400

Linux (Ubuntu/Debian)

# Register Microsoft repository
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install -y dotnet-sdk-8.0

Linux (Fedora/RHEL)

sudo dnf install dotnet-sdk-8.0

macOS

Using the installer or Homebrew:

brew install dotnet-sdk

Verifying Your Installation

Run the following commands to confirm everything works:

dotnet --list-sdks
dotnet --list-runtimes
dotnet --info

Expected output contains SDK version, runtimes, and architecture:

8.0.400 [/usr/share/dotnet/sdk]
Microsoft.NETCore.App 8.0.10 [/usr/share/dotnet/shared]

Editor Setup

Visual Studio Code

  1. Download VS Code from code.visualstudio.com
  2. Install the C# Dev Kit extension (ms-dotnettools.csdevkit)
  3. Install the C# extension (ms-dotnettools.csharp)

JetBrains Rider

Download from jetbrains.com/rider. Rider includes full .NET support out of the box. It offers Refactoring, debugging, and test runner integration.

Visual Studio

The Community edition is free. Select the ".NET desktop development" and "ASP.NET and web development" workloads during installation.

Creating Your First Project

The dotnet CLI includes project templates for every application type:

# Create a console application
dotnet new console -n MyFirstApp
cd MyFirstApp

This generates:

MyFirstApp/
├── Program.cs         # Main application code
├── MyFirstApp.csproj  # Project file (MSBuild XML)
├── obj/               # Intermediate build files
└── bin/               # Build output

Understanding the Project File

MyFirstApp.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
</Project>

Key elements:

  • OutputType: Whether the project produces an executable (Exe) or a library (Library)
  • TargetFramework: Which .NET version to target (net8.0, net9.0)
  • Nullable: Enables nullable reference types (recommended)
  • ImplicitUsings: Automatically includes common using directives

Building and Running

# Build the project
dotnet build

# Run the project
dotnet run

# Build in Release mode
dotnet build -c Release

# Publish for deployment
dotnet publish -c Release -o ./publish

Understanding the dotnet CLI

Command Purpose
dotnet new Create a new project from a template
dotnet build Build the project and its dependencies
dotnet run Build and run the project
dotnet test Run unit tests
dotnet publish Publish the app for deployment
dotnet pack Create a NuGet package
dotnet add package Add a NuGet package reference
dotnet restore Restore dependencies

Common Mistakes

Mistake 1: Installing Only the Runtime

The .NET Runtime lets you run apps, but the SDK is needed to build them. Always install the SDK, not just the runtime.

Mistake 2: Forgetting to Restart the Terminal

After installation, the dotnet command may not be found until you open a new terminal window. Always restart your terminal.

Mistake 3: Wrong Target Framework

Using net48 (for .NET Framework 4.8) when you mean net8.0 (for modern .NET 8). Modern projects should use net8.0 or later.

Mistake 4: Missing .NET Version Management

Multiple SDK versions can coexist. Use a global.json file to pin a specific version for your project.

Mistake 5: Ignoring ImplicitUsings

Modern .NET enables implicit usings by default, which automatically includes common namespaces. Disabling it without adding explicit usings leads to missing type errors.

Mistake 6: Not Using the Correct Template Name

dotnet new console creates a C# console app by default. Use dotnet new list to see all available templates.

Practice Questions

  1. What is the difference between dotnet build and dotnet run?
  2. How do you check which version of the .NET SDK is installed?
  3. What does the TargetFramework element in a .csproj file specify?
  4. Create a new console application, modify the code, and run it. What commands did you use?
  5. Why should you use ImplicitUsings in modern .NET projects?

Challenge

Install both .NET 8 SDK and .NET 9 SDK on your machine. Create a global.json file in a project directory that pins the project to .NET 8, then verify with dotnet --version that the correct SDK is used.

FAQ

Can I use C# without Visual Studio?

Yes. The dotnet CLI plus any text editor (VS Code, Sublime, vim) provides a complete development environment. JetBrains Rider is a popular alternative to Visual Studio.

What is the difference between .NET SDK and .NET Runtime?

The SDK includes the compiler, CLI tools, and the runtime. The runtime only allows running existing applications. For development, install the SDK. For production servers, only the runtime is needed.

How do I uninstall older .NET versions?

Use dotnet --list-sdks and dotnet --list-runtimes to see installed versions. On Windows, use Add/Remove Programs. On Linux, use the package manager. On macOS, use the uninstall script from Microsoft.

What is the difference between .csproj and .sln files?

A .csproj file defines a single project (settings, dependencies). A .sln (solution) file groups multiple related projects together. For simple projects, you only need the .csproj file.

Can I develop C# on a Chromebook?

Yes. You can use Visual Studio Code via the Linux container on Chrome OS. Install the .NET SDK inside the Linux environment and use the C# Dev Kit extension.

Why does my antivirus block dotnet commands?

Some antivirus software flags the dotnet compiler as suspicious because it generates executable code. Add the dotnet SDK directory and your project build output directories to the antivirus exclusion list.

Mini Project

Create a project that displays system information using the .NET environment APIs:

Create a new console app and replace Program.cs:

Console.WriteLine("=== System Information ===");
Console.WriteLine($"OS: {Environment.OSVersion}");
Console.WriteLine($".NET Version: {Environment.Version}");
Console.WriteLine($"Machine: {Environment.MachineName}");
Console.WriteLine($"User: {Environment.UserName}");
Console.WriteLine($"Processor Count: {Environment.ProcessorCount}");
Console.WriteLine($"64-bit OS: {Environment.Is64BitOperatingSystem}");
Console.WriteLine($"Current Directory: {Environment.CurrentDirectory}");

Build and run with:

dotnet new console -n SysInfo --force
# Replace Program.cs content
dotnet run

Expected output (varies by system):

=== System Information ===
OS: Microsoft Windows 10.0.22621
.NET Version: 8.0.10
Machine: MY-PC
User: developer
Processor Count: 8
64-bit OS: True
Current Directory: /home/user/projects/SysInfo

What's Next

Your development environment is ready. The next lesson covers writing your first C# program, understanding top-level statements, and learning how the Console class works for input and output.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro