Site

Tools — .NET Development Toolchain

Tutorial 2.0  •  C# / Learn

2.0 What This Teaches

This tutorial covers the tools you need for C# development:

2.1 The .NET SDK

The .NET SDK bundles three things: the Roslyn compiler (turns C# into IL bytecode), the .NET runtime (executes the bytecode), and the dotnet CLI (project management commands). Download it from https://dotnet.microsoft.com - choose the LTS release for stability. Verify your installation:
dotnet --version
dotnet --info
The SDK is needed to build and compile. The Runtime alone can run published apps but cannot compile source code. Install the SDK for development.

2.2 Creating Projects

dotnet new creates projects from templates. The most common templates:
CommandCreates
dotnet new console -n MyAppConsole application
dotnet new classlib -n MyLibClass library (DLL)
dotnet new xunit -n MyTestsxUnit test project
dotnet new webapi -n MyApiASP.NET Core Web API
List all available templates with dotnet new list.

2.3 Build and Run Commands

CommandAction
dotnet buildCompiles the project to bin/Debug/
dotnet runBuilds and runs the project
dotnet run --configuration ReleaseBuilds optimized release and runs
dotnet publishCreates a self-contained deployable output
dotnet cleanRemoves compiled output from bin/ and obj/
The obj/ folder holds intermediate build artifacts. The bin/ folder holds the compiled executable and DLLs. Both can be deleted safely - dotnet recreates them on the next build.

2.4 The .csproj File

The .csproj file controls how the project is built. The most important settings are in <PropertyGroup>:
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
</Project>
TargetFramework specifies which .NET version to target. Nullable enables nullable reference type analysis. ImplicitUsings auto-adds common namespaces.

2.5 NuGet Packages

NuGet is the .NET package manager. Add a package from the command line:
dotnet add package Newtonsoft.Json
dotnet add package Serilog --version 3.1.1
The package reference is added to your .csproj file automatically:
<ItemGroup>
  <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Run dotnet restore to download packages listed in the project file. This happens automatically on dotnet build and dotnet run. Browse packages at https://www.nuget.org.

2.6 IDE Options

IDEPlatformNotes
Visual Studio CommunityWindowsFull IDE, free for individual use; best debugging and refactoring tools
VS Code + C# Dev KitAllLightweight, cross-platform, free; good for smaller projects
JetBrains RiderAllCross-platform, commercial; excellent refactoring and code analysis

2.7 Exercise

Exercise Create a new console project with dotnet new console -n Greeting. Add the Humanizer NuGet package. Verify it appears in the .csproj file. Run dotnet build to confirm everything compiles. Then delete the bin/ and obj/ folders and rebuild to confirm dotnet recreates them.

2.8 Common Mistakes

Installing the Runtime instead of the SDK

The .NET Runtime can run published apps but cannot compile source code. If dotnet build fails with "The SDK was not found", you installed the Runtime only. Download and install the SDK from dotnet.microsoft.com.

Forgetting dotnet restore after cloning

NuGet packages are not committed to source control - only their references are in .csproj. After cloning a repository, run dotnet restore (or just dotnet build) to download them before running the project.

Mismatched TargetFramework

If a library targets net8.0 but your app targets net6.0, the build fails with a framework compatibility error. Ensure all projects in a solution target compatible framework versions.

2.9 Key Terms

TermMeaning
.NET SDKBundle containing the C# compiler, runtime, and dotnet CLI
RoslynThe open-source C# and VB.NET compiler
dotnet CLICommand-line interface for creating, building, and running .NET projects
.csprojXML project file defining framework, settings, and dependencies
TargetFrameworkThe .NET version to compile against (e.g., net8.0)
NuGetThe .NET package manager; packages hosted at nuget.org
dotnet restoreDownloads NuGet packages listed in .csproj
ImplicitUsingsProject setting that injects common using directives automatically