Special Offer: My C#/.NET Bootcamp Course is out now. Get 10% OFF using the code FRIENDS10.

Today, I want to share 13 C# NuGet packages with you that I think every .NET developer should know.

Introduction

Let’s clarify what I mean with C# libraries or packages that I think every .NET developer should know. I don’t mean that everyone needs to know every detail about them.

I have used several of those libraries myself and know them well enough. However, there are also libraries in this list that I don’t know in detail, and that’s okay.

However, they are good to know. For example, you come across a problem and instantly know that there is a well-known package that might be helpful to solve your problem.

All libraries and packages mentioned in this video are open-source, come with excellent documentation, and are regularly updated by generous members of the .NET community. Most of the packages are part of the .NET Foundation.

With that out of the way – let’s jump into the first package.

Quartz.Net

Quartz.Net is an open-source job scheduling system for .NET. You can implement jobs and schedule them using timer triggers, or you can define how many times a job should be executed.

You can embed Quartz.Net in any .NET application. Another option is to run it as a stand-alone process. The third option is to run a cluster of stand-alone programs with load balancing and fail-over capability.

You can use Quartz.Net in simple projects or advanced business scenarios. I used it in two different projects, and the customer was happy with the results in both cases.

Serilog

Serilog is a logging library for .NET applications. It supports structured data logging. It is easy to set up and has a clean API.

Serilog provides logging to almost every target you need with more than a hundred sinks. It includes various cloud services on major cloud platforms, databases, and more exotic solutions.

It’s my go-to solution for application logging. If you want to learn more about Serilog, check out my Introduction to Serilog video on this channel.

Automapper

Automapper is a tool that helps you copy data from one object structure to another. If you decouple your application into different layers or modules, you quickly copy data between different models.

It’s often boring code to write and maintain. Automapper supports conventions. You can, for example, map from one object to another based on the property names. Of course, it also handles much more complex situations.

In smaller projects, you might want to write the mapping code yourself. That’s fine. However, if you think you need help to solve that problem, Automapper offers a great solution.

Polly

Polly is a library that allows developers to express policies when handling API calls. You can define a retry policy, fallback policy, rate-limiting policy, and much more.

Besides .NET 6, Polly also supports a wide range of older .NET technologies because it targets .NET Standard 1.1.

Polly is a library that I haven’t used myself, but I heard so much positive feedback from the community that I wanted to include it in this list.

FakeItEasy

FakeItEasy is a .NET library that creates fake objects, mocks, stubs, and more. It has a very simple API and provides powerful methods to configure mocks the way you need them.

I know that Moq is very popular these days, but I have used FakeItEasy in several projects, and it’s still my go-to solution for mocking types in automated tests.

XUnit

XUnit is a community-focused, popular unit testing framework written by the original authors of NUnit v2. It has a very extensible, modern implementation.

xUnit integrates with most modern IDEs and, besides C#, also supports F# and VB.NET.

For simple projects, I mostly use MsTest. If I have a more significant project or want to implement better tests, xUnit is what I use.

FluentValidation

FluentValidation is a popular .NET library for building strongly-typed validation rules. It has an ASP.NET Core integration, provides an extensive list of built-in validators, and offers a simple API to create custom validators.

FluentValidation is especially helpful when you need to support multiple languages. All the built-in validators translate into the CurrentUICultre of the application, and you can provide localized messages for your custom validations.

I have used FluentValidation before, and I am considering using it for another project that I’m working on right now.

FluentAssertions

FluentAssertions offers an extensive set of extension methods to specify the expected outcome of a unit test. It supports many .NET versions and testing frameworks, including MsTest, xUnit, NUnit, and MSpec.

Besides half of the name, FluentAssertions and FluentValidation have nothing in common. However, both are great tools for solving their respective problems.

I usually use the default assertion methods when using xUnit, but I prefer FluentAssertions when working with MsTest. However, you can, of course, use it with MsTest too.

Autofac

Autofac is an Inversion of Control container for .NET applications. It has a simple but powerful API and supports a flexible module system.

For newer applications, I usually use the built-in dependency injection container. However, for WinForms or WPF applications based on the .NET Framework, Autofac is a great solution. 

I have used it in different projects, and I liked it so much that I made a whole dependency injection series about dependency injection with Autofac on this channel.

Noda Time

Noda Time is a date and time API for .NET. The built-in DateTime type has a few shortcomings that Noda Time aims to overcome by offering an adequate type system.

For example, DateTime doesn’t offer a type to represent a date and time in a specific time zone.

If you ever have to implement an application heavily depending on different points in time, probably including different time zones, consider Noda Time and see if it makes your life simpler.

SharpZipLib

SharpZipLib is a compression library that supports Zip files using various compression methods. It also supports different encryption algorithms.

If you want to compress data, for example, to combine multiple files into a single zip file before sending it to the client, SharpZibLib could be a great solution.

HtmlAgilityPack

HtmlAgilityPack is an HTML parser written in C#. You can use it to scrape websites and extract information from their HTML pages.

So far, I have used it in a single project, but I have had great success with it. It took me a few hours to get used to XPath, but in the end, it saved me hours of manual parsing.

MailKit

MailKit is a cross-platform .NET library. It provides a robust, fully-featured, and RFC-compliant IMAP, POP3, and SMTP client implementation.

If you need to send emails from your own servers instead of a cloud service, MailKit might be the library that safes your day.

I had to send emails in the past, and depending on how complex the definitions are, you might want to use MailKit instead of the built-in SmtpClient type.

What Is Your Favorite NuGet Package?

The .NET ecosystem is massive. There is so much more to explore. The 13 selected NuGet packages are my favorites, and I have used most of them in real-world projects.

Let me know in the comments what projects are missing and what packages you would add to the list of libraries that every .NET developer should know.

If you want to learn more about .NET development, subscribe to this channel and watch this video next.

 

Claudio Bernasconi

I'm an enthusiastic Software Engineer with a passion for teaching .NET development on YouTube, writing articles about my journey on my blog, and making people smile.