In order to support C# 6 in our Razor views on MVC5, we turned on the Roslyn compiler platform via web.config:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
</compilers>
</system.codedom>
However, after production deployments, each view/controller appears to have a noticeable "First Load" delay that is worse than without this compiler being enabled.
Importantly, this delay is in addition to the regular JIT delay you get from a new site being deployed. Pages are noticably slower, while it appears VBCSCompiler.exe runs in the background to "further compile" these pages.
Is there a best practice for pre-compiling/optimizing this situation to eliminate the first-load runtime delay post deployment? Ideally VBCSCompiler.exe is not running after a deployment occurs, and is performed at build-time.
I've seen mentions of aspnet_compiler.exe and have come across StackExchange.Precompilation (see https://blog.stackoverflow.com/2015/07/announcing-stackexchange-precompilation/) and wonder if this is the right fix.
Does anyone have any experience with this particular problem? Thank you.