Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to precompile a Web Application project?

I've heard recently that you can precompile Web Application projects. My question is how?

Right now, when I do a publish for my web application and select only files needed to run this application I get it published but it still has all my ASPX pages and it will still only JIT compile the pages. How do I make it so that all of the ASPX pages are precompiled before putting them on the server?

like image 563
Earlz Avatar asked Aug 27 '10 22:08

Earlz


People also ask

Which tool can be used to precompile a Windows application?

The ASP.NET compiler tool can also be used to precompile a site for deployment with a non-updatable UI.

What is pre compiling?

(computing) To compile in advance.

What ASP NET deployment method is used to Precompile Web site content before installation?

You can precompile a Web site using the Aspnet_compiler.exe tool on the command line. For more information, see How to: Precompile ASP.NET Web Sites for Deployment and ASP.NET Compilation Tool (Aspnet_compiler.exe). Visual Studio also includes commands to precompile a Web site from the IDE.


2 Answers

Unfortunately, the way to do this isn't spectacular. You would have to "deploy" the solution locally, then move it, or just compile it on the server where it will go. Either way uses aspnet_compiler.exe. See http://msdn.microsoft.com/en-us/library/ms227976%28v=VS.90%29.aspx for more details.

like image 27
Andrew Avatar answered Sep 24 '22 14:09

Andrew


You can download a project template called a Web Deployment Project (WDP) (VS2008 version here), which enhances the build and deployment features of Visual Studio. This basically wraps features of aspnet_compile.exe, but allows you to do this visually as part of your overall solution.

Besides pre-compilation, it also allows you do a number of interesting things, like config file replacement (great for deploying to different environments) and setting how your assemblies are built (per-page, per-site, etc.).

Two good Scott Guthrie blogs about this project type:

  • announcement of the tool for VS2008: http://weblogs.asp.net/scottgu/archive/2008/01/28/vs-2008-web-deployment-project-support-released.aspx
  • basic walk-through of the tool (VS2005 version, but it's basically the same in VS2008): http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx

I've used this project type for some VS2005 and VS2008 projects and it's invaluable (especially for those legacy web site projects!!).

I didn't know this was also in the MSDN library, but here's a nice article in MSDN for WDP's.

I hope this helps!

EDIT: WDP's exist for VS2005 and VS2010 also.

like image 151
David Hoerster Avatar answered Sep 23 '22 14:09

David Hoerster