ASP.NET 2.0 Web Site precompilcation

Published Mon, Aug 15 2005 0:57

Many times a day I hear harrowing yells of ASP.NET developers about new compilation model of ASP.NET. They don't believe they should give full source code of the project to customer. Actually, not! On-demand compilation is an extra feature but not the constraint to give the sources. You can decide what to do: publish the project with full source code and have a possibility to easily modify the project on the production server, or you can choose to deploy only markup in .ASPX files or deploy only binaries.

To go latter two ways, developer could use command-line compiler aspnet_compiler.exe or integrated Visual Studio tool called Publish Web Site.

Visual Studio 2005

1. Go to Build | Publish menu.

2. Specify the path where you want to have your ready-to-deploy project.
3. Check Allow this precompiled site to be updatable if you want to kepp markup in .ASPX files. If you not check this option you'll .ASPX files with a phrase This is a marker file generated by the precompilation tool, and should not be deleted! instead of actual markup and lots of binaries for every page in bin directory.


To precompile your project use the following command:

aspnet_compiler.exe -p application_path target_path

If you want your application to be updatable, use the following:

aspnet_compiler.exe -p application_path -u target_path

There are a plenty of command-line parameters that aspnet_compiler.exe understand, to view all of them, use -? parameter.

Pros and Contras

If you use site precompilation you avoid the first-time compilation stage but you lose an ability to use source code on the production server. As for me, sometimes it's extremely good to have such an ability. But it's you to choose!

by gaidar
Filed under: ,

Leave a Comment

If you can't read this number refresh your screen
Enter the numbers above: