Precompile your Web apps

This gets mentioned a dozen or so times whenever we decide on a launch date for a client site. But it never seems to sink in for some reason. I don’t know if it’s because it’s not considered to be crucial or if people are somehow uncomfortable not being able to read their .aspx files.

There are times you need to include code with your project, but sometimes, consistency and efficiency are more important. Distribute the code seperately!

I know, a lot of people don’t have access to Visual Studio, and others don’t like to use the Express editions for various reasons in certain projects. I’m not excluded in this. I sometimes use Notepad to write quick apps just to save time (or I’m lazy).

Here’s a simple solution:
Create a .bat file in your app directory.
Put this in it..

C:WindowsMicrosoft.NETFrameworkv2.0.50727aspnet_compiler.exe -p C:app -v / C:cmp -u

This line compliles the app with provisions for you to modify it later (-u).

When it’s time to compile your project, just run the .bat file.

There is a detailed explanation of precompilation on MSDN. Replace “C:app” with the destination of your app and “C:cmp” with the output directory you want to compile to. Change the framework version first if you are not using 2.0.

A list of available versions on your computer should be under the /Framework directory. If you don’t have a particular version, it should be listed under Windows Update.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s