Fix SelfHost to default to config environment

Fixes MusicStore
This commit is contained in:
Hao Kung 2014-11-21 15:01:52 -08:00
parent 63c8e1889b
commit 2f02fc6091
2 changed files with 4 additions and 1 deletions

View File

@ -38,6 +38,10 @@ namespace Microsoft.AspNet.Hosting
config.AddCommandLine(args);
var serviceCollection = HostingServices.Create(_serviceProvider, config);
serviceCollection.AddInstance<IConfigureHostingEnvironment>(new ConfigureHostingEnvironment(env =>
{
env.EnvironmentName = config.Get(EnvironmentKey) ?? DefaultEnvironmentName;
}));
var services = serviceCollection.BuildServiceProvider();
var appEnv = services.GetRequiredService<IApplicationEnvironment>();

View File

@ -57,7 +57,6 @@ namespace Microsoft.AspNet.TestHost
var services = HostingServices.Create(serviceProvider);
services.AddSingleton<IConfigureHostingEnvironment, ConfigureTestHostingEnvironment>();
//var appServices = BuildFallbackServiceProvider(services, serviceProvider);
var appServices = services.BuildServiceProvider();
var config = new Configuration();
return new TestServer(config, appServices, app);