#269 Use a json file instead of an ini file to configure hosting.
This commit is contained in:
parent
5fb45b3cfb
commit
1b790467a1
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
private const string HostingIniFile = "Microsoft.AspNet.Hosting.ini";
|
private const string HostingJsonFile = "Microsoft.AspNet.Hosting.json";
|
||||||
private const string ConfigFileKey = "config";
|
private const string ConfigFileKey = "config";
|
||||||
|
|
||||||
private readonly IServiceProvider _serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
|
@ -25,11 +25,11 @@ namespace Microsoft.AspNet.Hosting
|
||||||
// Allow the location of the ini file to be specified via a --config command line arg
|
// Allow the location of the ini file to be specified via a --config command line arg
|
||||||
var tempBuilder = new ConfigurationBuilder().AddCommandLine(args);
|
var tempBuilder = new ConfigurationBuilder().AddCommandLine(args);
|
||||||
var tempConfig = tempBuilder.Build();
|
var tempConfig = tempBuilder.Build();
|
||||||
var configFilePath = tempConfig[ConfigFileKey] ?? HostingIniFile;
|
var configFilePath = tempConfig[ConfigFileKey] ?? HostingJsonFile;
|
||||||
|
|
||||||
var appBasePath = _serviceProvider.GetRequiredService<IApplicationEnvironment>().ApplicationBasePath;
|
var appBasePath = _serviceProvider.GetRequiredService<IApplicationEnvironment>().ApplicationBasePath;
|
||||||
var builder = new ConfigurationBuilder(appBasePath);
|
var builder = new ConfigurationBuilder(appBasePath);
|
||||||
builder.AddIniFile(configFilePath, optional: true);
|
builder.AddJsonFile(configFilePath, optional: true);
|
||||||
builder.AddEnvironmentVariables();
|
builder.AddEnvironmentVariables();
|
||||||
builder.AddCommandLine(args);
|
builder.AddCommandLine(args);
|
||||||
var config = builder.Build();
|
var config = builder.Build();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
"Microsoft.Framework.Configuration": "1.0.0-*",
|
"Microsoft.Framework.Configuration": "1.0.0-*",
|
||||||
"Microsoft.Framework.Configuration.CommandLine": "1.0.0-*",
|
"Microsoft.Framework.Configuration.CommandLine": "1.0.0-*",
|
||||||
"Microsoft.Framework.Configuration.EnvironmentVariables": "1.0.0-*",
|
"Microsoft.Framework.Configuration.EnvironmentVariables": "1.0.0-*",
|
||||||
"Microsoft.Framework.Configuration.Ini": "1.0.0-*",
|
"Microsoft.Framework.Configuration.Json": "1.0.0-*",
|
||||||
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
|
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
|
||||||
"Microsoft.Framework.Logging": "1.0.0-*",
|
"Microsoft.Framework.Logging": "1.0.0-*",
|
||||||
"Microsoft.Dnx.Runtime.Abstractions": "1.0.0-*",
|
"Microsoft.Dnx.Runtime.Abstractions": "1.0.0-*",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue