Skip to content

Installation ​

Install the packages you need:

bash
dotnet add package NResilience              # Core engine, policy values, and HttpClient policy
dotnet add package NResilience.Extensions   # Dependency injection, configuration, and metrics
dotnet add package NResilience.Testing      # Scripted callbacks and recording listeners
dotnet add package NResilience.Grpc         # The gRPC client interceptor
dotnet add package NResilience.AspNetCore   # Middleware that reads an inbound deadline

Package details ​

PackageUse caseDepends on
NResilienceAlways. This contains the full API, including HTTP support.None
NResilience.ExtensionsUse for projects with a DI container, configuration, or OpenTelemetry.NResilience, Microsoft.Extensions.*
NResilience.TestingUse in test projects.NResilience
NResilience.GrpcUse for a gRPC client. See gRPC.NResilience, NResilience.Extensions, Grpc.*
NResilience.AspNetCoreUse in a service that should inherit its callers' deadlines.NResilience, ASP.NET Core

NResilience has no external dependencies, targets net8.0 and net10.0, and works with Native AOT and trimming. The HttpClient policy is included in the core package so you only need one package for the common case.

NResilience.AspNetCore is one middleware and nothing else. It is a separate package because it is the only part of NResilience that requires the ASP.NET Core shared framework, which a worker or console app should not carry - see deadline propagation.

NResilience.Grpc is separate because it depends on Grpc.Core.Api and Grpc.Net.ClientFactory, and the core package maintains its no-dependencies promise. A gRPC client already pulls in most of that weight.

NResilience.Extensions is separate because it depends on the Microsoft.Extensions.* family. Use the core package in libraries to avoid imposing a hosting model on your consumers; use the extensions package in applications with a DI container.

Which package do I need? ​

If you call an HTTP API from an ASP.NET Core application, install NResilience.Extensions (which includes NResilience) and register the resilience policy:

csharp
services.AddHttpClient<Client>().AddResilience();

For more information, see Dependency injection.

Released under the MIT License.