Eagerly initialize hosting environment
This commit is contained in:
parent
b6a3fee088
commit
4cbda0358b
|
|
@ -159,15 +159,8 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
var hostingServices = BuildHostingServices();
|
var hostingServices = BuildHostingServices();
|
||||||
var hostingContainer = hostingServices.BuildServiceProvider();
|
var hostingContainer = hostingServices.BuildServiceProvider();
|
||||||
|
|
||||||
var appEnvironment = hostingContainer.GetRequiredService<IApplicationEnvironment>();
|
|
||||||
var startupLoader = hostingContainer.GetRequiredService<IStartupLoader>();
|
var startupLoader = hostingContainer.GetRequiredService<IStartupLoader>();
|
||||||
|
|
||||||
var contentRootPath = ResolveContentRootPath(_options.ContentRootPath, appEnvironment.ApplicationBasePath);
|
|
||||||
var applicationName = ResolveApplicationName() ?? appEnvironment.ApplicationName;
|
|
||||||
|
|
||||||
// Initialize the hosting environment
|
|
||||||
_hostingEnvironment.Initialize(applicationName, contentRootPath, _options);
|
|
||||||
|
|
||||||
var host = new WebHost(hostingServices, startupLoader, _options, _config);
|
var host = new WebHost(hostingServices, startupLoader, _options, _config);
|
||||||
|
|
||||||
// Only one of these should be set, but they are used in priority
|
// Only one of these should be set, but they are used in priority
|
||||||
|
|
@ -184,6 +177,14 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
_options = new WebHostOptions(_config);
|
_options = new WebHostOptions(_config);
|
||||||
|
|
||||||
|
var defaultPlatformServices = PlatformServices.Default;
|
||||||
|
var appEnvironment = defaultPlatformServices.Application;
|
||||||
|
var contentRootPath = ResolveContentRootPath(_options.ContentRootPath, appEnvironment.ApplicationBasePath);
|
||||||
|
var applicationName = ResolveApplicationName() ?? appEnvironment.ApplicationName;
|
||||||
|
|
||||||
|
// Initialize the hosting environment
|
||||||
|
_hostingEnvironment.Initialize(applicationName, contentRootPath, _options);
|
||||||
|
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
services.AddSingleton(_hostingEnvironment);
|
services.AddSingleton(_hostingEnvironment);
|
||||||
|
|
||||||
|
|
@ -218,8 +219,6 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
// Ensure object pooling is available everywhere.
|
// Ensure object pooling is available everywhere.
|
||||||
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
|
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
|
||||||
|
|
||||||
var defaultPlatformServices = PlatformServices.Default;
|
|
||||||
|
|
||||||
services.AddSingleton(defaultPlatformServices.Application);
|
services.AddSingleton(defaultPlatformServices.Application);
|
||||||
services.AddSingleton(defaultPlatformServices.Runtime);
|
services.AddSingleton(defaultPlatformServices.Runtime);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue