Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
#276 #277 Fix ini loading, read location from command line.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed May 20, 2015
1 parent b75a855 commit 2168176
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/Microsoft.AspNet.Hosting/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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<IApplicationEnvironment>().ApplicationBasePath;
var config = new ConfigurationSection(appBasePath);
config.AddIniFile(configFilePath, optional: true);
config.AddEnvironmentVariables();
config.AddCommandLine(args);

Expand Down

0 comments on commit 2168176

Please sign in to comment.