I was wondering if the following is possible :
Yes you can do this. The view engine will recompile all the files in each directory into a separate DLL into a file like this
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\micropedi_mvc\d3b5b4cd\eb219373\App_global.asax.ihdiifed.DLL
You can use ILSpy
or Reflector
to open up this file and see exactly which files were compiled to it. if you have many directories you'll see several DLLs generated.
Note that all that
MvcBuildViews` does is run this post build event which just does the same as if you were to hit each file needed for your application.
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
For maximum performance I'd recommend the RazorGenerator precompiler. This actually embeds the cshtml files into your main DLL which isn't what MvcBuildViews does at all. Plus its much faster.
If you wanted to use this in production you'd need to change UsePhysicalViewsIfNewer
in RazorGeneratorMvcStart.cs
to true so that it would recompile if you updated the view.
Tip: If you ever want to find exactly which DLL the cshtml file is compiled to just add this to your page
<div>This file is compiled to @this.GetType().Assembly.CodeBase</div>
Then you'll get the full path without looking for it.
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