diff --git a/src/Microsoft.AspNet.Hosting/Program.cs b/src/Microsoft.AspNet.Hosting/Program.cs index eb9e2eccbf..6004d8e50f 100644 --- a/src/Microsoft.AspNet.Hosting/Program.cs +++ b/src/Microsoft.AspNet.Hosting/Program.cs @@ -23,14 +23,16 @@ namespace Microsoft.AspNet.Hosting public void Main(string[] args) { // Allow the location of the ini file to be specfied via a --config command line arg - var tempConfig = new ConfigurationSection().AddCommandLine(args); + var tempBuilder = new ConfigurationBuilder().AddCommandLine(args); + var tempConfig = tempBuilder.Build(); var configFilePath = tempConfig[ConfigFileKey] ?? HostingIniFile; var appBasePath = _serviceProvider.GetRequiredService().ApplicationBasePath; - var config = new ConfigurationSection(appBasePath); - config.AddIniFile(configFilePath, optional: true); - config.AddEnvironmentVariables(); - config.AddCommandLine(args); + var builder = new ConfigurationBuilder(appBasePath); + builder.AddIniFile(configFilePath, optional: true); + builder.AddEnvironmentVariables(); + builder.AddCommandLine(args); + var config = builder.Build(); var host = new WebHostBuilder(_serviceProvider, config).Build(); using (host.Start()) diff --git a/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs b/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs index 7e204b3b96..4ae42e9c46 100644 --- a/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs +++ b/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs @@ -42,7 +42,8 @@ namespace Microsoft.AspNet.Hosting private string _serverFactoryLocation; private IServerFactory _serverFactory; - public WebHostBuilder([NotNull] IServiceProvider services) : this(services, config: new ConfigurationSection()) { } + public WebHostBuilder([NotNull] IServiceProvider services) + : this(services, config: new ConfigurationBuilder().Build()) { } public WebHostBuilder([NotNull] IServiceProvider services, [NotNull] IConfiguration config) { diff --git a/src/Microsoft.AspNet.TestHost/TestServer.cs b/src/Microsoft.AspNet.TestHost/TestServer.cs index 4bc34a517c..3dfacf4b59 100644 --- a/src/Microsoft.AspNet.TestHost/TestServer.cs +++ b/src/Microsoft.AspNet.TestHost/TestServer.cs @@ -79,7 +79,7 @@ namespace Microsoft.AspNet.TestHost { return new WebHostBuilder( services ?? CallContextServiceLocator.Locator.ServiceProvider, - config ?? new ConfigurationSection()); + config ?? new ConfigurationBuilder().Build()); } public static WebHostBuilder CreateBuilder() diff --git a/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs b/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs index 268a91a7d3..8c16801d1d 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs @@ -50,8 +50,9 @@ namespace Microsoft.AspNet.Hosting { "server", "Microsoft.AspNet.Hosting.Tests" } }; - var config = new ConfigurationSection() + var builder = new ConfigurationBuilder() .Add(new MemoryConfigurationSource(vals)); + var config = builder.Build(); var host = CreateBuilder(config).Build(); host.Start(); Assert.NotNull(host.ApplicationServices.GetRequiredService()); @@ -65,8 +66,9 @@ namespace Microsoft.AspNet.Hosting { "Hosting:Server", "Microsoft.AspNet.Hosting.Tests" } }; - var config = new ConfigurationSection() + var builder = new ConfigurationBuilder() .Add(new MemoryConfigurationSource(vals)); + var config = builder.Build(); var host = CreateBuilder(config).Build(); host.Start(); Assert.NotNull(host.ApplicationServices.GetRequiredService()); @@ -155,8 +157,9 @@ namespace Microsoft.AspNet.Hosting { "ASPNET_ENV", "Staging" } }; - var config = new ConfigurationSection() + var builder = new ConfigurationBuilder() .Add(new MemoryConfigurationSource(vals)); + var config = builder.Build(); var engine = CreateBuilder(config).Build(); var env = engine.ApplicationServices.GetRequiredService(); @@ -171,8 +174,9 @@ namespace Microsoft.AspNet.Hosting { "Hosting:Environment", "Staging" } }; - var config = new ConfigurationSection() + var builder = new ConfigurationBuilder() .Add(new MemoryConfigurationSource(vals)); + var config = builder.Build(); var engine = CreateBuilder(config).Build(); var env = engine.ApplicationServices.GetRequiredService(); @@ -382,7 +386,7 @@ namespace Microsoft.AspNet.Hosting { return new WebHostBuilder( CallContextServiceLocator.Locator.ServiceProvider, - config ?? new ConfigurationSection()); + config ?? new ConfigurationBuilder().Build()); } public IServerInformation Initialize(IConfiguration configuration) diff --git a/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs b/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs index e65c0130e7..23ae59567b 100644 --- a/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs +++ b/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNet.TestHost Assert.Throws( () => TestServer.Create( services, - new ConfigurationSection(), new Startup().Configure, configureServices: null)); + new ConfigurationBuilder().Build(), new Startup().Configure, configureServices: null)); } [Fact]