D20Tek.Spectre.Console.Extensions.MoreContainers
1.57.1
dotnet add package D20Tek.Spectre.Console.Extensions.MoreContainers --version 1.57.1
NuGet\Install-Package D20Tek.Spectre.Console.Extensions.MoreContainers -Version 1.57.1
<PackageReference Include="D20Tek.Spectre.Console.Extensions.MoreContainers" Version="1.57.1" />
<PackageVersion Include="D20Tek.Spectre.Console.Extensions.MoreContainers" Version="1.57.1" />
<PackageReference Include="D20Tek.Spectre.Console.Extensions.MoreContainers" />
paket add D20Tek.Spectre.Console.Extensions.MoreContainers --version 1.57.1
#r "nuget: D20Tek.Spectre.Console.Extensions.MoreContainers, 1.57.1"
#:package D20Tek.Spectre.Console.Extensions.MoreContainers@1.57.1
#addin nuget:?package=D20Tek.Spectre.Console.Extensions.MoreContainers&version=1.57.1
#tool nuget:?package=D20Tek.Spectre.Console.Extensions.MoreContainers&version=1.57.1
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 AutofacContainerBuilderas the type registrar.CommandAppBuilderExtensions.WithLamarContainer(this CommandAppBuilder, ServiceRegistry?, ServiceLifetime)- uses a LamarServiceRegistryas the type registrar.CommandAppBuilderExtensions.WithLightInjectContainer(this CommandAppBuilder, ServiceContainer?, ServiceLifetime)- uses a LightInjectServiceContaineras the type registrar.CommandAppBuilderExtensions.WithNinjectContainer(this CommandAppBuilder, StandardKernel?)- uses a NinjectStandardKernelas 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 | Versions 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. |
-
net10.0
- Autofac (>= 9.3.2)
- D20Tek.Spectre.Console.Extensions (>= 1.57.1)
- Lamar (>= 16.0.0)
- LightInject (>= 7.1.0)
- Ninject (>= 3.3.6)
- SimpleInjector (>= 5.6.0)
- Spectre.Console (>= 0.57.2)
- Spectre.Console.Cli (>= 0.55.0)
-
net9.0
- Autofac (>= 9.3.2)
- D20Tek.Spectre.Console.Extensions (>= 1.57.1)
- Lamar (>= 16.0.0)
- LightInject (>= 7.1.0)
- Ninject (>= 3.3.6)
- SimpleInjector (>= 5.6.0)
- Spectre.Console (>= 0.57.2)
- Spectre.Console.Cli (>= 0.55.0)
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.1 | 88 | 9/4/2026 |
| 1.56.1 | 379 | 6/10/2026 |
| 1.55.1 | 133 | 4/21/2026 |
| 1.54.3 | 138 | 3/27/2026 |
| 1.54.2 | 133 | 2/13/2026 |
| 1.54.1 | 137 | 1/9/2026 |
| 1.53.1 | 330 | 11/11/2025 |
| 1.52.2 | 160 | 10/18/2025 |
| 1.51.1.1 | 356 | 9/17/2025 |
| 1.50.1.7 | 228 | 7/31/2025 |
| 1.50.1.6 | 204 | 7/28/2025 |
| 1.50.1.5 | 231 | 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.