C# VS2026
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:

  1. Package Manager Console (Tools → NuGet → Package Manager Console):
    Install-Package Newtonsoft.Json
  2. CLI:
    dotnet add package Serilog
  3. GUI: Right-click project → Manage NuGet Packages → search and install.

Popular Packages

PackagePurpose
SerilogStructured logging
DapperLightweight SQL ORM
AutoMapperObject-to-object mapping
FluentValidationValidation rules
PollyResilience and retry policies
CsvHelperReading and writing CSV files
BogusGenerating 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>