IHostBuilder Interface

Definition

A program initialization abstraction.

public interface class IHostBuilder
public interface IHostBuilder
type IHostBuilder = interface
Public Interface IHostBuilder
Derived

Properties

Properties

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

Methods

Build()

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

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>)

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

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>)

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

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

Overrides the factory used to create the service provider.

UseServiceProviderFactory<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder>)

Overrides the factory used to create the service provider.

Extension Methods

UseApplicationMetadata(IHostBuilder, String)

Registers a configuration provider for application metadata and binds a model object onto the configuration.

AddFakeLoggingOutputSink(IHostBuilder, Action<String>)

Adds an action invoked on each log message.

Configure(IHostBuilder, Action<IHostBuilder>)

Exposes IHostBuilder for changes via a delegate.

ConfigureAppConfiguration(IHostBuilder, String, String)

Adds a configuration value.

ConfigureAppConfiguration(IHostBuilder, ValueTuple<String,String>[])

Adds configuration entries.

ConfigureHostConfiguration(IHostBuilder, String, String)

Adds a configuration value.

ConfigureHostConfiguration(IHostBuilder, ValueTuple<String,String>[])

Adds configuration entries.

Start(IHostBuilder)

Builds and starts the host.

StartAsync(IHostBuilder, CancellationToken)

Builds and starts the host.

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>)

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

ConfigureDefaults(IHostBuilder, String[])

Configures an existing IHostBuilder instance with pre-configured defaults. This will overwrite previously configured values and is intended to be called before additional configuration calls.

ConfigureHostOptions(IHostBuilder, Action<HostBuilderContext,HostOptions>)

Adds a delegate for configuring the HostOptions of the IHost.

ConfigureHostOptions(IHostBuilder, Action<HostOptions>)

Adds a delegate for configuring the HostOptions of the IHost.

ConfigureLogging(IHostBuilder, Action<HostBuilderContext,ILoggingBuilder>)

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

ConfigureLogging(IHostBuilder, Action<ILoggingBuilder>)

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

ConfigureMetrics(IHostBuilder, Action<IMetricsBuilder>)

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

ConfigureMetrics(IHostBuilder, Action<HostBuilderContext,IMetricsBuilder>)

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

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)

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

RunConsoleAsync(IHostBuilder, CancellationToken)

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

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.

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)

Specify the content root directory to be used by the host. To avoid the content root directory being overwritten by a default value, ensure this is called after defaults are configured.

UseDefaultServiceProvider(IHostBuilder, Action<ServiceProviderOptions>)

Specify the IServiceProvider to be the default one.

UseDefaultServiceProvider(IHostBuilder, Action<HostBuilderContext,ServiceProviderOptions>)

Specify the IServiceProvider to be the default one.

UseEnvironment(IHostBuilder, String)

Specify the environment to be used by the host. To avoid the environment being overwritten by a default value, ensure this is called after defaults are configured.

UseSystemd(IHostBuilder)

Configures the IHost lifetime to SystemdLifetime, provides notification messages for application started and stopping, and configures console logging to the systemd format.

UseWindowsService(IHostBuilder, Action<WindowsServiceLifetimeOptions>)

Sets the host lifetime to WindowsServiceLifetime and enables logging to the event log with the application name as the default source name.

UseWindowsService(IHostBuilder)

Sets the host lifetime to WindowsServiceLifetime and enables logging to the event log with the application name as the default source name.

Applies to