2.0 What This Teaches
This tutorial covers the tools you need for C# development:
- The .NET SDK and what it contains
- Creating and managing projects with the dotnet CLI
- The
.csproj project file format
- Adding packages with NuGet
- IDE options 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:
| Command | Creates |
| dotnet new console -n MyApp | Console application |
| dotnet new classlib -n MyLib | Class library (DLL) |
| dotnet new xunit -n MyTests | xUnit test project |
| dotnet new webapi -n MyApi | ASP.NET Core Web API |
List all available templates with dotnet new list.
2.3 Build and Run Commands
| Command | Action |
| dotnet build | Compiles the project to bin/Debug/ |
| dotnet run | Builds and runs the project |
| dotnet run --configuration Release | Builds optimized release and runs |
| dotnet publish | Creates a self-contained deployable output |
| dotnet clean | Removes 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
| IDE | Platform | Notes |
| Visual Studio Community | Windows | Full IDE, free for individual use; best debugging and refactoring tools |
| VS Code + C# Dev Kit | All | Lightweight, cross-platform, free; good for smaller projects |
| JetBrains Rider | All | Cross-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
| Term | Meaning |
| .NET SDK | Bundle containing the C# compiler, runtime, and dotnet CLI |
| Roslyn | The open-source C# and VB.NET compiler |
| dotnet CLI | Command-line interface for creating, building, and running .NET projects |
| .csproj | XML project file defining framework, settings, and dependencies |
| TargetFramework | The .NET version to compile against (e.g., net8.0) |
| NuGet | The .NET package manager; packages hosted at nuget.org |
| dotnet restore | Downloads NuGet packages listed in .csproj |
| ImplicitUsings | Project setting that injects common using directives automatically |