Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MvcBuildViews Versus Razor Generator

What differences are there between using the .csproj setting MvcBuildViews and using Razor Generator to achieve the same thing?

My own presumption is that MvcBuildViews does not make intelli-sense of views available to unit tests, but what other differences might there be?

like image 754
Brent Arias Avatar asked May 15 '12 20:05

Brent Arias


People also ask

What is MvcBuildViews?

The main take-away of this post is: MvcBuildViews is here to make building of views as part of web application building process. It doesn't generate any output to binaries folder. Views are precompiled during publishing process and precompiling happens only if views are not expected to be modified.

Do Cshtml files get compiled?

cshtml extension are compiled at both build and publish time using the Razor SDK. Runtime compilation may be optionally enabled by configuring your project.


1 Answers

MVCBuildViews doesn't actually pre-compile your views for deployment. It's compiling the views after building your solution to echo any errors that may be in any of your MVC views before you deploy. This way you can catch compile errors for Views before pushing them to your server to avoid the error page or yellow screen of death at runtime.

The RazorGenerator can be used to pre-compile your views to avoid any compiling warmup times on the first hit of any View on your server. When using the RazorGenerator tool you can deploy the assembly for the application instead of the Views Folder, since all the views will be pre-compiled and contained inside that assembly.

like image 94
Gabe Avatar answered Nov 08 '22 03:11

Gabe