|
9 | 9 | using System.Runtime.ExceptionServices; |
10 | 10 | using Microsoft.AspNetCore.Hosting.Builder; |
11 | 11 | using Microsoft.AspNetCore.Hosting.Internal; |
12 | | -using Microsoft.AspNetCore.Hosting.Server; |
13 | 12 | using Microsoft.AspNetCore.Http; |
14 | 13 | using Microsoft.Extensions.Configuration; |
15 | 14 | using Microsoft.Extensions.DependencyInjection; |
@@ -47,14 +46,8 @@ public WebHostBuilder() |
47 | 46 | ?? Environment.GetEnvironmentVariable("Hosting:Environment") |
48 | 47 | ?? Environment.GetEnvironmentVariable("ASPNET_ENV")); |
49 | 48 |
|
50 | | - if (Environment.GetEnvironmentVariable("Hosting:Environment") != null) |
51 | | - { |
52 | | - Console.WriteLine("The environment variable 'Hosting:Environment' is obsolete and has been replaced with 'ASPNETCORE_ENVIRONMENT'"); |
53 | | - } |
54 | | - if (Environment.GetEnvironmentVariable("ASPNET_ENV") != null) |
55 | | - { |
56 | | - Console.WriteLine("The environment variable 'ASPNET_ENV' is obsolete and has been replaced with 'ASPNETCORE_ENVIRONMENT'"); |
57 | | - } |
| 49 | + // Add the default server.urls key |
| 50 | + UseSetting(WebHostDefaults.ServerUrlsKey, Environment.GetEnvironmentVariable("ASPNETCORE_URLS")); |
58 | 51 | } |
59 | 52 |
|
60 | 53 | /// <summary> |
@@ -133,6 +126,17 @@ public IWebHostBuilder ConfigureLogging(Action<ILoggerFactory> configureLogging) |
133 | 126 | /// </summary> |
134 | 127 | public IWebHost Build() |
135 | 128 | { |
| 129 | + // Warn about deprecated environment variables |
| 130 | + if (Environment.GetEnvironmentVariable("Hosting:Environment") != null) |
| 131 | + { |
| 132 | + Console.WriteLine("The environment variable 'Hosting:Environment' is obsolete and has been replaced with 'ASPNETCORE_ENVIRONMENT'"); |
| 133 | + } |
| 134 | + |
| 135 | + if (Environment.GetEnvironmentVariable("ASPNET_ENV") != null) |
| 136 | + { |
| 137 | + Console.WriteLine("The environment variable 'ASPNET_ENV' is obsolete and has been replaced with 'ASPNETCORE_ENVIRONMENT'"); |
| 138 | + } |
| 139 | + |
136 | 140 | var hostingServices = BuildHostingServices(); |
137 | 141 | var hostingContainer = hostingServices.BuildServiceProvider(); |
138 | 142 |
|
@@ -192,7 +196,7 @@ private IServiceCollection BuildHostingServices() |
192 | 196 | try |
193 | 197 | { |
194 | 198 | var startupType = StartupLoader.FindStartupType(_options.StartupAssembly, _hostingEnvironment.EnvironmentName); |
195 | | - |
| 199 | + |
196 | 200 | if (typeof(IStartup).GetTypeInfo().IsAssignableFrom(startupType.GetTypeInfo())) |
197 | 201 | { |
198 | 202 | services.AddSingleton(typeof(IStartup), startupType); |
|
0 commit comments