-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Still seeing runtime compilation when using StackExchange.Precompilation.Build #38
Comments
You can get more details on what is happening by hooking into the following events: StackExchange.Precompilation.RoslynRazorViewEngine.CompilingPath += OnRuntimeCompilation;
System.Web.WebPages.Razor.RazorBuildProvider.CompilingPath += OnRuntimeCompilation; ... and have the handler log it somewhere: private static void OnRuntimeCompilation(object sender, System.Web.WebPages.Razor.CompilingPathEventArgs e)
{
// TODO log details somewhere
} There are also other thing asp.net tries to build at runtime, like global.asax, helpers, etc. There is a workaround for global.asax in the test project via the PreApplicationStartMethodAttribute and the correct handler. If you're sure you're not using anything else, you can also add a PrecompiledApp.config to you web application project with the following content: <?xml version="1.0"?>
<precompiledApp version="42" updatable="true"/> It tells the BuildManager not to attempt building any special-purpose folders such as App_Code, App_GlobalResources, and App_WebReferences, and special files such as Global.asax. |
Thanks for the helpful information and suggestions. I added trace output for those events, applied the global.asax workaround and create the PrecompiledApp.config file. The traces show a runtime compilation event whenever a "new" .cshtml page is requested. In other words, if the same page is requested multiple times, the event only occurs for the first request. The sender of the events is always System.Web.WebPages.Razor.RazorBuildProvider. |
You can get a list of all precompiled views the precompiled view engine knows about via the |
I have two web projects in the same solution, one for sign-in and the other for whatever. The sign-in app never fires a runtime compilation event when its pages are requested. But the admin app wants to runtime-compile every page other than "~/index.cshtml". While debugging, For example, I've spent hours looking for relevant differences between the two apps, including detailed file diffs, but haven't found anything that seems important. The sign-in app has a lot less pages (10 instead of 89) but I can't imagine that would matter. |
We use HttpContext.RewritePath for most incoming requests (primarily to remove cache-busting fingerprints). Could the resulting changes to the Request cause the caching not to locate the correct precompiled file? |
Maybe, if you use partial view names (e.g. |
Adding to this, I found that using the package with VS2015, I consistently get this error message:
Using VS2017, we do not see these build errors. Following the guide to copy the DLLs into the tools directory results in a different error when using VS2015:
For now I have migrated to VS2017, Is this likely to be due to the MSBuild version used? Or related to dependency resolution? |
I believe I've followed the necessary steps to use precompiled .cshtml views but when I run my web app and click on various pages, I still see significant delays and see VBCSCompiler.exe appearing in Task Manager, leading me to believe that the precompiled views are not being used.
Do I have the wrong expectations about what this package does or am I doing something wrong?
I followed these steps, per the instructions on github:
In the build output I've verified StackExchange.Precompiler.exe is being run, and while debugging I've verified PrecompiledViewEngine is finding what seem to be precompiled views in the project's assembly. And yet, I still see long delays and VBCSCompiler being run whenever new cshtml views are accessed.
The text was updated successfully, but these errors were encountered: