I have an ASP .Net MVC5 website, I have performance issues, I want to pre-compile the razor views and exclude them when deploying my website in IIS, I followed the steps indicated in this article but I got an error : RazorGenerator.targets was not found, in fact I checked in the package folder I din't find this file. Do you have any idea why this dll not found in the package folder ? The RazorGenerator.Mvc and RazorGenerator.MsBuild are installed correctly. Thanks in advance
Asked
Active
Viewed 1.9k times
15
-
Why not just use static html files? – Mark Homer Nov 12 '15 at 15:08
-
My views are not static, I retrieve some data from db – Bilel Chaouadi Nov 12 '15 at 15:11
1 Answers
21
You don't need RazorGenerator for this. When publishing just set the option to "Precompile during publishing", under "File Publish Options" on the "Settings" tab. Click "Configure" and then tick "Merge all outputs to a single assembly". Give it a unique name, generally something like [ProjectName].Precompiled
.

Chris Pratt
- 232,153
- 36
- 385
- 444
-
2Can you please explain me where can i find this settings, I'm using webdeploy? – Bilel Chaouadi Nov 12 '15 at 16:03
-
1It's in the publish dialog. There's a Settings tab at the left, and then under where you choose the configuration you want to deploy is a down arrow button labeled "File Publish Options". – Chris Pratt Nov 12 '15 at 16:32
-
1ok thank you for your answer, I got the following error : It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. – Bilel Chaouadi Nov 12 '15 at 17:29
-
I have just deleted the obj folder, the error gone now, I get another one, it says that the namespace log4net could not be found , it uninstall it then I reinstall it but the error persist – Bilel Chaouadi Nov 13 '15 at 08:49
-
17Is there any way to compile views during normal builds instead of a publish? – Russell Horwood Jul 20 '16 at 11:47
-
3https://blog.rsuter.com/precompile-asp-net-mvc-razor-views-in-release-mode-to-find-errors-at-compile-time/ @NineTails this should help – Neeraj Gulia Nov 28 '16 at 12:36
-
3I also have a question on SO here: https://stackoverflow.com/questions/48715367/how-can-i-get-precompiled-razor-files-when-deploying-net-web-application that relates to this answer as well. Making sure that the checkbox "Allow precompiled site to be updateable" is unchecked to have precompiled views. – John Dover Feb 12 '18 at 15:39