IHostBuilder IHostBuilder IHostBuilder Interface

Definition

A program initialization abstraction.

public interface IHostBuilder
type IHostBuilder = interface
Public Interface IHostBuilder
Derived

Properties

Properties Properties Properties

A central location for sharing state between components during the host building process.

Methods

Build() Build() Build()

Run the given actions to initialize the host. This can only be called once.

ConfigureAppConfiguration(Action<HostBuilderContext,IConfigurationBuilder>) ConfigureAppConfiguration(Action<HostBuilderContext,IConfigurationBuilder>) ConfigureAppConfiguration(Action<HostBuilderContext,IConfigurationBuilder>)

Sets up the configuration for the remainder of the build process and application. This can be called multiple times and the results will be additive. The results will be available at Configuration for subsequent operations, as well as in Services.

ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext,TContainerBuilder>) ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext,TContainerBuilder>) ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext,TContainerBuilder>)

Enables configuring the instantiated dependency container. This can be called multiple times and the results will be additive.

ConfigureHostConfiguration(Action<IConfigurationBuilder>) ConfigureHostConfiguration(Action<IConfigurationBuilder>) ConfigureHostConfiguration(Action<IConfigurationBuilder>)

Set up the configuration for the builder itself. This will be used to initialize the IHostEnvironment for use later in the build process. This can be called multiple times and the results will be additive.

ConfigureServices(Action<HostBuilderContext,IServiceCollection>) ConfigureServices(Action<HostBuilderContext,IServiceCollection>) ConfigureServices(Action<HostBuilderContext,IServiceCollection>)

Adds services to the container. This can be called multiple times and the results will be additive.

UseServiceProviderFactory<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder>) UseServiceProviderFactory<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder>) UseServiceProviderFactory<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder>)

Overrides the factory used to create the service provider.

UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext,IServiceProviderFactory<TContainerBuilder>>) UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext,IServiceProviderFactory<TContainerBuilder>>) UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext,IServiceProviderFactory<TContainerBuilder>>)

Overrides the factory used to create the service provider.

Extension Methods

Start(IHostBuilder) Start(IHostBuilder) Start(IHostBuilder)

Builds and starts the host.

StartAsync(IHostBuilder, CancellationToken) StartAsync(IHostBuilder, CancellationToken) StartAsync(IHostBuilder, CancellationToken)

Builds and starts the host.

ConfigureAppConfiguration(IHostBuilder, Action<IConfigurationBuilder>) ConfigureAppConfiguration(IHostBuilder, Action<IConfigurationBuilder>) ConfigureAppConfiguration(IHostBuilder, Action<IConfigurationBuilder>)

Sets up the configuration for the remainder of the build process and application. This can be called multiple times and the results will be additive. The results will be available at Configuration for subsequent operations, as well as in Services.

ConfigureContainer<TContainerBuilder>(IHostBuilder, Action<TContainerBuilder>) ConfigureContainer<TContainerBuilder>(IHostBuilder, Action<TContainerBuilder>) ConfigureContainer<TContainerBuilder>(IHostBuilder, Action<TContainerBuilder>)

Enables configuring the instantiated dependency container. This can be called multiple times and the results will be additive.

ConfigureLogging(IHostBuilder, Action<HostBuilderContext,ILoggingBuilder>) ConfigureLogging(IHostBuilder, Action<HostBuilderContext,ILoggingBuilder>) ConfigureLogging(IHostBuilder, Action<HostBuilderContext,ILoggingBuilder>)

Adds a delegate for configuring the provided ILoggingBuilder. This may be called multiple times.

ConfigureLogging(IHostBuilder, Action<ILoggingBuilder>) ConfigureLogging(IHostBuilder, Action<ILoggingBuilder>) ConfigureLogging(IHostBuilder, Action<ILoggingBuilder>)

Adds a delegate for configuring the provided ILoggingBuilder. This may be called multiple times.

ConfigureServices(IHostBuilder, Action<IServiceCollection>) ConfigureServices(IHostBuilder, Action<IServiceCollection>) ConfigureServices(IHostBuilder, Action<IServiceCollection>)

Adds services to the container. This can be called multiple times and the results will be additive.

RunConsoleAsync(IHostBuilder, Action<ConsoleLifetimeOptions>, CancellationToken) RunConsoleAsync(IHostBuilder, Action<ConsoleLifetimeOptions>, CancellationToken) RunConsoleAsync(IHostBuilder, Action<ConsoleLifetimeOptions>, CancellationToken)

Enables console support, builds and starts the host, and waits for Ctrl+C or SIGTERM to shut down.

RunConsoleAsync(IHostBuilder, CancellationToken) RunConsoleAsync(IHostBuilder, CancellationToken) RunConsoleAsync(IHostBuilder, CancellationToken)

Enables console support, builds and starts the host, and waits for Ctrl+C or SIGTERM to shut down.

UseConsoleLifetime(IHostBuilder) UseConsoleLifetime(IHostBuilder) UseConsoleLifetime(IHostBuilder)

Listens for Ctrl+C or SIGTERM and calls StopApplication() to start the shutdown process. This will unblock extensions like RunAsync and WaitForShutdownAsync.

UseConsoleLifetime(IHostBuilder, Action<ConsoleLifetimeOptions>) UseConsoleLifetime(IHostBuilder, Action<ConsoleLifetimeOptions>) UseConsoleLifetime(IHostBuilder, Action<ConsoleLifetimeOptions>)

Listens for Ctrl+C or SIGTERM and calls StopApplication() to start the shutdown process. This will unblock extensions like RunAsync and WaitForShutdownAsync.

UseContentRoot(IHostBuilder, String) UseContentRoot(IHostBuilder, String) UseContentRoot(IHostBuilder, String)

Specify the content root directory to be used by the host.

UseDefaultServiceProvider(IHostBuilder, Action<ServiceProviderOptions>) UseDefaultServiceProvider(IHostBuilder, Action<ServiceProviderOptions>) UseDefaultServiceProvider(IHostBuilder, Action<ServiceProviderOptions>)
UseDefaultServiceProvider(IHostBuilder, Action<HostBuilderContext,ServiceProviderOptions>) UseDefaultServiceProvider(IHostBuilder, Action<HostBuilderContext,ServiceProviderOptions>) UseDefaultServiceProvider(IHostBuilder, Action<HostBuilderContext,ServiceProviderOptions>)
UseEnvironment(IHostBuilder, String) UseEnvironment(IHostBuilder, String) UseEnvironment(IHostBuilder, String)

Specify the environment to be used by the host.

Applies to