Add compilation services when adding Razor.

#3383
This commit is contained in:
N. Taylor Mullen 2015-10-22 10:59:01 -07:00
parent f2af02b1cb
commit 8623946784
1 changed files with 7 additions and 0 deletions

View File

@ -11,6 +11,7 @@ using Microsoft.AspNet.Mvc.Razor.Directives;
using Microsoft.AspNet.Mvc.Razor.Internal; using Microsoft.AspNet.Mvc.Razor.Internal;
using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using Microsoft.Dnx.Compilation;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.OptionsModel; using Microsoft.Extensions.OptionsModel;
@ -117,6 +118,12 @@ namespace Microsoft.Extensions.DependencyInjection
// Internal for testing. // Internal for testing.
internal static void AddRazorViewEngineServices(IServiceCollection services) internal static void AddRazorViewEngineServices(IServiceCollection services)
{ {
if (CompilationServices.Default != null)
{
services.TryAdd(ServiceDescriptor.Instance(CompilationServices.Default.LibraryExporter));
services.TryAdd(ServiceDescriptor.Instance(CompilationServices.Default.CompilerOptionsProvider));
}
services.TryAddEnumerable( services.TryAddEnumerable(
ServiceDescriptor.Transient<IConfigureOptions<MvcViewOptions>, MvcRazorMvcViewOptionsSetup>()); ServiceDescriptor.Transient<IConfigureOptions<MvcViewOptions>, MvcRazorMvcViewOptionsSetup>());
services.TryAddEnumerable( services.TryAddEnumerable(