Host.CreateDefaultBuilder Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateDefaultBuilder() |
Initializes a new instance of the HostBuilder class with preconfigured defaults. |
CreateDefaultBuilder(String[]) |
Initializes a new instance of the HostBuilder class with preconfigured defaults. |
CreateDefaultBuilder()
Initializes a new instance of the HostBuilder class with preconfigured defaults.
public:
static Microsoft::Extensions::Hosting::IHostBuilder ^ CreateDefaultBuilder();
public static Microsoft.Extensions.Hosting.IHostBuilder CreateDefaultBuilder ();
static member CreateDefaultBuilder : unit -> Microsoft.Extensions.Hosting.IHostBuilder
Public Shared Function CreateDefaultBuilder () As IHostBuilder
Returns
The initialized IHostBuilder.
Remarks
The following defaults are applied to the returned HostBuilder:
- Set the ContentRootPath to the result of GetCurrentDirectory().
- Load host IConfiguration from "DOTNET_" prefixed environment variables.
- Load app IConfiguration from 'appsettings.json' and 'appsettings.[EnvironmentName].json'.
- Load app IConfiguration from User Secrets when EnvironmentName is 'Development' using the entry assembly.
- Load app IConfiguration from environment variables.
- Configure the ILoggerFactory to log to the console, debug, and event source output.
- Enable scope validation on the dependency injection container when EnvironmentName is 'Development'.
Applies to
CreateDefaultBuilder(String[])
Initializes a new instance of the HostBuilder class with preconfigured defaults.
public:
static Microsoft::Extensions::Hosting::IHostBuilder ^ CreateDefaultBuilder(cli::array <System::String ^> ^ args);
public static Microsoft.Extensions.Hosting.IHostBuilder CreateDefaultBuilder (string[] args);
public static Microsoft.Extensions.Hosting.IHostBuilder CreateDefaultBuilder (string[]? args);
static member CreateDefaultBuilder : string[] -> Microsoft.Extensions.Hosting.IHostBuilder
Public Shared Function CreateDefaultBuilder (args As String()) As IHostBuilder
Parameters
- args
- String[]
The command line arguments.
Returns
The initialized IHostBuilder.
Remarks
The following defaults are applied to the returned HostBuilder:
- Set the ContentRootPath to the result of GetCurrentDirectory().
- Load host IConfiguration from "DOTNET_" prefixed environment variables.
- Load host IConfiguration from supplied command line arguments.
- Load app IConfiguration from 'appsettings.json' and 'appsettings.[EnvironmentName].json'.
- Load app IConfiguration from User Secrets when EnvironmentName is 'Development' using the entry assembly.
- Load app IConfiguration from environment variables.
- Load app IConfiguration from supplied command line arguments.
- Configure the ILoggerFactory to log to the console, debug, and event source output.
- Enable scope validation on the dependency injection container when EnvironmentName is 'Development'.