This project is read-only.

Why are Razor Generator's features not built into MsBuild or Visual Studio?

Nov 14, 2012 at 4:23 PM

I'm currently using MVC 4 and just added Razor Generator to my project. I found a blog article written by Jim Lamb written in April 20, 2010:

Jim says you can turn on compile-time view checking for ASP.NET MVC Projects using MsBuild. I am left with a couple of questions:

1. The blog article says "compile-time view checking" and not compiled views.  Does it only precompile the views for the purposes of checking compiler errors and not for full compilation of views as Razor Generator does? The fact that it is done during an AfterBuild step, leads me to conclude that it doesn't.

2. If my conclusion is correct, is there a good reason why it doesn't do a full compilation? Why go through the trouble of adding this feature without going the extra mile of doing what Razor Generator does?

3. If my conclusion is incorrect, why do we need Razor Generator?

Thanks in advance.


Nov 14, 2012 at 5:07 PM

Good question! The goals are quite different:

MvcBuildViews is simply about making sure that your view can compile, but it doesn't produce any artifact. In other words, after you deploy your app, it makes absolutely no difference whether you had turned on MvcBuildViews or not. The runtime execution model is unchanged.

On the other hand, RazorGenerator completely changes the runtime execution model, by having the pages end up as assemblies, such that the cshtml files are not needed at all at runtime (well, in some scenarios, it's still interesting to include them as an override, but let's ignore that here).

Of course, using RazorGenerator will also make sure that your views can compile, so in that sense, it is a super-set of MvcBuildViews. But it's also a very different model that may not be right for everyone.

Nov 14, 2012 at 5:23 PM

Is there a plan to include RazorGenerator's functionality into future MVC releases?

Nov 14, 2012 at 5:26 PM

Not a clear plan right now, but I agree this is something we should move toward.