Lesson 29 of 30
NuGet Packages and Project Management
C# in Visual Studio 2026 — a hands-on guide for developers at every level.
What is NuGet?
NuGet is the package manager for .NET. It hosts hundreds of thousands of open-source libraries you can add to your project with a single command or a few clicks in Visual Studio.
Installing Packages
Three ways to install a NuGet package:
- Package Manager Console (Tools → NuGet → Package Manager Console):
Install-Package Newtonsoft.Json - CLI:
dotnet add package Serilog - GUI: Right-click project → Manage NuGet Packages → search and install.
Popular Packages
| Package | Purpose |
|---|---|
Serilog | Structured logging |
Dapper | Lightweight SQL ORM |
AutoMapper | Object-to-object mapping |
FluentValidation | Validation rules |
Polly | Resilience and retry policies |
CsvHelper | Reading and writing CSV files |
Bogus | Generating fake test data |
Project Structure Best Practices
MyApp/
├── MyApp.sln
├── MyApp.Core/ # Domain models, interfaces
├── MyApp.Infrastructure/ # EF Core, file access
├── MyApp.Api/ # ASP.NET Core Web API
└── MyApp.Tests/ # xUnit tests
The .csproj File
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog" Version="3.*" />
</ItemGroup>
</Project>