-
I find that this method is called twice in WebHost.cs -> CreateDefaultBuilder(string[] args) aspnetcore/src/DefaultBuilder/src/WebHost.cs Lines 164 to 167 in 450e047 and aspnetcore/src/DefaultBuilder/src/WebHost.cs Lines 187 to 190 in 450e047 But I see the following code in WebHostBuilder.cs -> BuildCommonServices(out AggregateException? hostingStartupErrors) aspnetcore/src/Hosting/Hosting/src/WebHostBuilder.cs Lines 271 to 273 in 450e047 The new builder seems to contain the value of _config, and _config already has CommandLine config in it, so I don't quite understand why it's called twice. I'm sorry my English isn't very good😳 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
There are two stages to config. In the first one a few sources are loaded so the host itself can be configured. This is used to read things like ASPNETCORE_ENVIRONMENT, ContentRoot, etc.. aspnetcore/src/DefaultBuilder/src/WebHost.cs Lines 164 to 167 in b7b3001 Later the host builds a config for the application. It starts with a copy of the host config so the app can re-use those values, and layers everything else on top of that. This is where things like AppSettings.Development.json are added, using the environment and the content root from the host config. aspnetcore/src/Hosting/Hosting/src/WebHostBuilder.cs Lines 271 to 275 in b7b3001 |
Beta Was this translation helpful? Give feedback.
There are two stages to config. In the first one a few sources are loaded so the host itself can be configured. This is used to read things like ASPNETCORE_ENVIRONMENT, ContentRoot, etc..
aspnetcore/src/DefaultBuilder/src/WebHost.cs
Lines 164 to 167 in b7b3001
Later the host builds a config for the application. It starts with a copy of the host config so the app can re-use those values, and layers everything else on top of that. This is where things like AppSettings.Development.json are added, using the environment and the content root from the host con…