From 21681761490266ce9b8b519f841abeb97ac46b38 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 20 May 2015 16:10:58 -0700 Subject: [PATCH] #276 #277 Fix ini loading, read location from command line. --- src/Microsoft.AspNet.Hosting/Program.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.AspNet.Hosting/Program.cs b/src/Microsoft.AspNet.Hosting/Program.cs index e9e7ca52..eb9e2ecc 100644 --- a/src/Microsoft.AspNet.Hosting/Program.cs +++ b/src/Microsoft.AspNet.Hosting/Program.cs @@ -2,10 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNet.Hosting.Internal; using Microsoft.Framework.Configuration; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Runtime; @@ -15,6 +11,7 @@ namespace Microsoft.AspNet.Hosting public class Program { private const string HostingIniFile = "Microsoft.AspNet.Hosting.ini"; + private const string ConfigFileKey = "config"; private readonly IServiceProvider _serviceProvider; @@ -25,11 +22,13 @@ public Program(IServiceProvider serviceProvider) public void Main(string[] args) { - var config = new ConfigurationSection(); - if (File.Exists(HostingIniFile)) - { - config.AddIniFile(HostingIniFile); - } + // Allow the location of the ini file to be specfied via a --config command line arg + var tempConfig = new ConfigurationSection().AddCommandLine(args); + 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);