我用下面的(伪)代码编译了一些Razor视图:
var host = new RazorEngineHost(new CSharpRazorCodeLanguage());
var engine = new RazorTemplateEngine(host);
var razorResult = engine.GenerateCode(reader, viewTypeName, "", null);
var compilerParameters = new CompilerParameters(assemblies.ToArray(), outputAssemblyName);
compilerParameters.TempFiles.KeepFiles = false;
var codeProvider = new CSharpCodeProvider();
var compilationResults = codeProvider.CompileAssemblyFromDom(compilerParameters, razorResult.GeneratedCode);
在.NET 4.5中,对于一个相当复杂的视图,这需要10秒。自升级到.NET 4.6以来,这需要几秒钟:(
我引用了Microsoft.CodeDom.Providers.DotNetCompilerPlatform
改变了什么?我有什么可以做的吗?