HostBuilder HostBuilder HostBuilder Class

Definition

A program initialization utility.

public class HostBuilder : Microsoft.Extensions.Hosting.IHostBuilder
type HostBuilder = class
    interface IHostBuilder
Public Class HostBuilder
Implements IHostBuilder
Inheritance
HostBuilderHostBuilderHostBuilder
Implements

Constructors

HostBuilder() HostBuilder() HostBuilder()

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 IHostingEnvironment 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.

Extension Methods

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

Start the host and listen on the specified urls.

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, 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.

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

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

UseEnvironment(IHostBuilder, String) UseEnvironment(IHostBuilder, String) UseEnvironment(IHostBuilder, String)

Specify the environment to be used by the host.

Applies to