D20Tek.Spectre.Console.Extensions.MoreContainers 1.57.2

dotnet add package D20Tek.Spectre.Console.Extensions.MoreContainers --version 1.57.2
                    
NuGet\Install-Package D20Tek.Spectre.Console.Extensions.MoreContainers -Version 1.57.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="D20Tek.Spectre.Console.Extensions.MoreContainers" Version="1.57.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="D20Tek.Spectre.Console.Extensions.MoreContainers" Version="1.57.2" />
                    
Directory.Packages.props
<PackageReference Include="D20Tek.Spectre.Console.Extensions.MoreContainers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add D20Tek.Spectre.Console.Extensions.MoreContainers --version 1.57.2
                    
#r "nuget: D20Tek.Spectre.Console.Extensions.MoreContainers, 1.57.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package D20Tek.Spectre.Console.Extensions.MoreContainers@1.57.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=D20Tek.Spectre.Console.Extensions.MoreContainers&version=1.57.2
                    
Install as a Cake Addin
#tool nuget:?package=D20Tek.Spectre.Console.Extensions.MoreContainers&version=1.57.2
                    
Install as a Cake Tool

NuGet

D20Tek.Spectre.Console.Extensions.MoreContainers

D20Tek.Spectre.Console.Extensions.MoreContainers provides additional dependency injection container integrations for Spectre.Console.Cli. It supplies ITypeRegistrar and ITypeResolver implementations and fluent CommandAppBuilder hooks for the Autofac, Lamar, LightInject, and Ninject containers.

This is a separate package that references the core D20Tek.Spectre.Console.Extensions package. It keeps the third-party container dependencies out of the core package, so applications that use the built-in Microsoft.Extensions.DependencyInjection container do not pay for them.

Why a separate package?

The core library integrates the Microsoft.Extensions.DependencyInjection container out of the box. Not every application needs an alternative container, and each supported container brings its own transitive dependencies. Isolating these integrations here keeps the core package lean while still giving teams a first-class option for their preferred container.

Installation

dotnet add package D20Tek.Spectre.Console.Extensions.MoreContainers

Supported containers

The package adds fluent CommandAppBuilder extension methods for the following containers:

  • Autofac - WithAutofacContainer
  • Lamar - WithLamarContainer
  • LightInject - WithLightInjectContainer
  • Ninject - WithNinjectContainer

Each method sets the builder's type registrar to the container-specific implementation, so Spectre.Console resolves command types and their dependencies from that container.

Usage

Call the container-specific hook on CommandAppBuilder instead of the core WithDIContainer method. Each hook optionally accepts a pre-configured container instance; when omitted, a new empty container is created.

Autofac

using Autofac;
using D20Tek.Spectre.Console.Extensions;

return await new CommandAppBuilder()
                 .WithAutofacContainer()
                 .WithDefaultCommand<GreetCommand>()
                 .Build()
                 .RunAsync(args);

Lamar

WithLamarContainer also accepts an optional default ServiceLifetime (defaults to Singleton) that applies to its registrations:

using D20Tek.Spectre.Console.Extensions;
using Lamar;
using Microsoft.Extensions.DependencyInjection;

return await new CommandAppBuilder()
                 .WithLamarContainer(lifetime: ServiceLifetime.Singleton)
                 .WithDefaultCommand<GreetCommand>()
                 .Build()
                 .RunAsync(args);

LightInject

WithLightInjectContainer accepts an optional default ServiceLifetime (defaults to Singleton):

using D20Tek.Spectre.Console.Extensions;
using Microsoft.Extensions.DependencyInjection;

return await new CommandAppBuilder()
                 .WithLightInjectContainer(lifetime: ServiceLifetime.Singleton)
                 .WithDefaultCommand<GreetCommand>()
                 .Build()
                 .RunAsync(args);

Ninject

using D20Tek.Spectre.Console.Extensions;

return await new CommandAppBuilder()
                 .WithNinjectContainer()
                 .WithDefaultCommand<GreetCommand>()
                 .Build()
                 .RunAsync(args);

Providing a pre-configured container

Each hook accepts an existing container so you can register your own services before Spectre.Console adds its command types:

using Autofac;
using D20Tek.Spectre.Console.Extensions;

var container = new ContainerBuilder();
container.RegisterType<GreetingService>().As<IGreetingService>().SingleInstance();

return await new CommandAppBuilder()
                 .WithAutofacContainer(container)
                 .WithDefaultCommand<GreetCommand>()
                 .Build()
                 .RunAsync(args);

Public API

  • CommandAppBuilderExtensions.WithAutofacContainer(this CommandAppBuilder, ContainerBuilder?) - uses an Autofac ContainerBuilder as the type registrar.
  • CommandAppBuilderExtensions.WithLamarContainer(this CommandAppBuilder, ServiceRegistry?, ServiceLifetime) - uses a Lamar ServiceRegistry as the type registrar.
  • CommandAppBuilderExtensions.WithLightInjectContainer(this CommandAppBuilder, ServiceContainer?, ServiceLifetime) - uses a LightInject ServiceContainer as the type registrar.
  • CommandAppBuilderExtensions.WithNinjectContainer(this CommandAppBuilder, StandardKernel?) - uses a Ninject StandardKernel as the type registrar.
  • AutofacTypeRegistrar / AutofacTypeResolver, LamarTypeRegistrar / LamarTypeResolver, LightInjectTypeRegistrar / LightInjectTypeResolver, NinjectTypeRegistrar / NinjectTypeResolver - the container-specific bridge types.

Samples

For runnable examples, see the container-specific samples in the repository:

Feedback

If you have any feedback, questions, or issues, please open an issue on the GitHub repository.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.57.2 0 9/12/2026
1.57.1 90 9/4/2026
1.56.1 379 6/10/2026
1.55.1 134 4/21/2026
1.54.3 138 3/27/2026
1.54.2 133 2/13/2026
1.54.1 138 1/9/2026
1.53.1 331 11/11/2025
1.52.2 161 10/18/2025
1.51.1.1 357 9/17/2025
1.50.1.7 230 7/31/2025
1.50.1.6 205 7/28/2025
1.50.1.5 232 7/1/2025
1.50.1.4 169 6/21/2025
1.50.1.3 372 6/9/2025
1.50.1.2 194 6/7/2025
1.50.1 245 6/5/2025

Split off additional dependency injection containers into this package to minimize dependencies in the core package.