.NET Top NuGet Packages Every Developer Should Know in 2022

There are a lot of implementations for commonly-used concepts, and most of the trivial problems you face were solved by someone. When facing a new programming challenge, it is always a good habit to check for existing solutions. Maybe they are open for usage and can save a lot of time.

2022 Top NuGet Packages

I want to share the list of the most used .NET NuGet packages that I prefer to use. They are pretty helpful in your day-to-day development life.

note: You are welcome to tell in comments about any package which you think helps developers a lot but was not added to this list.

Flurl

A simple library that allows building URLs together with Fluent Http makes any HTTP calls much more effortless. Also, creators added support for a convenient way of using it during unit testing. In most cases, it helps when you need to interact with third-party API.

1
2
dotnet add package Flurl
dotnet add package Flurl.Http

Read more in offiacial documentation:

https://flurl.dev/docs/fluent-http/

Polly

This library provides great resilient and fault-tolerant tools. It allows implementing circuit breakers, retries, fallbacks, rate limits, and timeouts. If your application interacts with third-party services, you must use this package to configure resilient policies when external service goes down.

1
dotnet add package Polly

Take a look at this article with the best ways to use Polly:

How to Use Polly in .NET

FluentValidation

The package helps to validate models with business rules. It provides a convenient way to describe rules for model properties. It contains a lot of built-in validators, and you also can build your own, which adheres to your business rules.

1
dotnet add package FluentValidation

The next article shows how to leverage FluentValidation for input model validation with ASP.NET:

Model Validation Using FluentValidation in ASP.NET

AutoMapper

Handy object to object mapper. It helps avoid routine property mapping and provides an interface on how to describe property mapping from input object to output object.

It`s a good practice to avoid exposing internal entities. This approach requires mapping from the input model to internal entities and mapping from the internal to the output model. AutoMapper makes this process much more manageable.

1
dotnet add package AutoMapper

Official getting started Guide

NSwag

Working with web API, it`s a good practice to provide documentation for consumers. OpenAPI is a standard for API documentation, and NSwag is a package that adds the ability to generate API documentation on the fly without additional efforts according to OpenAPI specification.

1
dotnet add package NSwag.AspNetCore

Take a look how to configure NSwag for Asp.NET Application

Serilog

The package provides a formatted logging ability, it has a lot of supported sinks. In most cases, you will find a required sink for your project.

1
dotnet add package Serilog --version 2.10.0

Take a look at documentation page here

NUnit

There are few testing frameworks available for .NET. NUnit is one of them. It offers a good variety of tools for unit tests. Probably most developers use it or xUnit, which is pretty similar to this one.

1
2
dotnet add package NUnit --version 3.13.2
dotnet add package NUnit3TestAdapter --version 4.0.0

Read a difference between NUnit and another popular testing framework XUnit

FluentAssertions

This is another helpful package for unit tests, and it makes asserts much cleaner. No need to write custom object comparisons or create code to compare arrays. Delegate most of the day-to-day trivial assertion tasks to fluent assertions

1
dotnet add package FluentAssertions --version 6.4.0

Read about fluent assertions more in official site

Moq

We ofter need to mock something during tests, and Moq provides perfect tools for this purpose. It mocks interfaces, and even if you want classes. It definitely must be a part of the test project.

1
dotnet add package Moq --version 4.16.1

Read about Moq more in official site

Conclusion

There are a lot of packages that help you write a good API. You can check a comprehensive list of awesome .net packages and pick one that perfectly suits you.