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

Fix ini loading, read location from command line. #280

Merged
merged 1 commit into from
May 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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