Pre-compiling ASP.NET

I recently had the fun of writing an ASP.net site that made extensive use of a number of 3.5 features - extension methods, LINQ-to-SQL, LINQ-to-XML, etc. When the time came to deploy the site, I was dismayed to find out the host had not and would not install .NET 3.5 on the server.

This is when I found out about pre-compiling ASP.NET code (specifically aspnet-compiler.exe) - it saved the day. I'm sure this is the sort of thing that experienced ASP.NET developers already know about, but for a developer that doesn't write ASP.NET sites all that often, this is just fantastic.

The primary benefit of pre-compiling is performance - avoiding the delay in spinning up the .NET application upon first visit. As a side-effect, since my server didn't have the 3.5 compiler, my application would not run. But since it has been compiled ahead of time and linked to the 3.5 binaries, it will run in the environment.

The down side is, so far, I haven't found the right way to deploy all the needed dependencies automatically - probably because my development and deployment environment are both 3.5 whereas the hosting environment is 2.0. I find I have to copy any of the 3.5 binaries needed by hand - minor inconvenience at this point.

I haven't automated it yet either, I'm still working out the best way to fit this into the deployment process and the best set of options to use. But the results are clear - my 3.5 code runs on a 2.0 server.



Tags

  • .NET

Revisions

  • 2/16/2010 - Article published.