Don't add platforms services if no available

This commit is contained in:
David Fowler 2015-10-22 06:13:25 -07:00
parent 10822b3b4f
commit f2e7c49c36
1 changed files with 15 additions and 7 deletions

View File

@ -92,13 +92,21 @@ namespace Microsoft.AspNet.Hosting
_configureServices(services);
}
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Application));
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Runtime));
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.AssemblyLoadContextAccessor));
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.AssemblyLoaderContainer));
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.LibraryManager));
services.TryAdd(ServiceDescriptor.Instance(CompilationServices.Default.LibraryExporter));
services.TryAdd(ServiceDescriptor.Instance(CompilationServices.Default.CompilerOptionsProvider));
if (PlatformServices.Default != null)
{
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Application));
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.Runtime));
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.AssemblyLoadContextAccessor));
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.AssemblyLoaderContainer));
services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.LibraryManager));
}
// TODO: Remove this
if (CompilationServices.Default != null)
{
services.TryAdd(ServiceDescriptor.Instance(CompilationServices.Default.LibraryExporter));
services.TryAdd(ServiceDescriptor.Instance(CompilationServices.Default.CompilerOptionsProvider));
}
return services;
}