11

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?

3 Answers 3

7

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:

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Everyone should be aware that in VS2010 there is a bug in Web Deployment Projects that causes it to build all files, including those that are "excluded" in the project. This is extremely annoying if you use excluded files, and effectively breaks the approach.
What would be great is if there were a way to customize the Publish command to precompile...
1

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.

Comments

0

When you publish the site, uncheck the option that says "Allow this precompiled site to be updateable".

1 Comment

that's only for "Web Site" projects. not "Web Application"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.