We have a project and would like to build the views to generate compile time errors if there is anything wrong within the Views' .cshtml files.
Still, compile time increases drastically:
MvcBuildViews = true
takes 62 secondsMvcBuildViews = false
takes 9 secondsIs this something acceptable? Cause the increase is quite drastic in which we cannot stand having to wait for such compile times. Any way we can improve such compilation?
The project up till now consists around 130 Views & Partial Views (.cshtml files). Is this considered to be large / medium / small?
Well I think having the possibility to compile the views is a good thing by itself but I cannot wait that long either.
So what I prefer to do is to add that MvcBuildViews = true
inside the ProperyGroup
of Release so that you only Compile the views at the Release time and before deployment
The property group should look like this:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
So put your
<MvcBuildViews>true</MvcBuildViews>
Inside this Release block. this way you still compile your views once and not every time you try to debug...
We struggled with the same problem. We began compiling Views in order to catch obvious issues that would creep up on us during Integration Tests and UX Tests. Even worse were the bugs that somehow crept into production.
But, as you noticed, our build times became intolerable. Like you, our developers build countless times and that became a major part of our day. We had jokes about testing after lunch so the build could be done while we were out.
We eventually moved to building before UX-tests.
Now we are moving toward pre-compiling. Only one guy on our team has adopted it for now and apparently pre-compiles are noticably better than builds (incremental vs total). And setup is basically a nuget fetch.
These articles should be a good start
http://stacktoheap.com/blog/2013/01/19/precompiling-razor-views-in-asp-dot-net-mvc-3/
http://blog.davidebbo.com/2011/06/precompile-your-mvc-views-using.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With