Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What effect does the new precompile during publishing option have on MVC4 applications?

So I recently updated Visual Studio 2012 to Update 2. Lo and behold, the next time I go to publish my application (via File Publish in this case) I notice that there are three new options:

  1. Delete all existing files prior to publish
  2. Precompile during publishing (with a link to Configure)
  3. Exclude files from the App_Data folder

The first and third options are pretty self-explanatory, but I can't find any documentation on the second option as it applies to MVC. When I check it, there doesn't seem to be any change in the files produced on the site and I don't see any real change in performance.

like image 524
Elsimer Avatar asked Apr 23 '13 21:04

Elsimer


People also ask

What does Precompile during publishing do?

The default (checked) setting of "Allow precompiled site to be updateable" allows you to update your view content without needing to rebuild the entire project.

What is precompiled app config?

It's used to indicate whether or not the ASPX/ASCX pages in your site are updateable or not. You can precompile and have the code behind compiled, but leave these pages updateable so you can make minor GUI-related tweaks should you wish.

What is precompiled code in asp net?

Precompiling for Deployment and Updateaspx files into single files that use the compiled code-behind model and copies them to the layout. This option enables you to make limited changes to the ASP.NET Web pages in the site after you compile them.


2 Answers

Using the ASP.NET precompiler can have the following impact on your MVC app:

  • If you have anything in App_Code, it will be precompiled into a DLL before deployment. Without precompiling, this would happen on the fly by the ASP.NET runtime.
  • If you choose the option to not make your pages updateable (i.e. uncheck the first checkbox in the advanced settings dialog), it will also precompile your views (ASPX and Razor) instead of compiling those dynamically at runtime as well. The default (checked) setting of "Allow precompiled site to be updateable" allows you to update your view content without needing to rebuild the entire project.

If you don't have any files in App_Code and you want your site to remain updateable, it doesn't seem to do much.

like image 79
Jimmy Avatar answered Oct 09 '22 18:10

Jimmy


It is an old question, but I just encounter similar issue and feel something worth sharing.

My error message is same in this post. My project is MVC5, build with Visual Studio 2013 professional. Compilation Error: The type 'ASP.global_asax' exists in both DLLs

In my case, with precompile option, there is a file, App_global.asax.dll, in bin folder, and cause above error message. First, I remove App_global.asax.dll on server, restart application pool, issue is gone. Then I tried another approach, uncheck precompile and republish, redeploy to server, issue is gone.

like image 35
flexflow Avatar answered Oct 09 '22 16:10

flexflow