How to include different Javascript files depending on build configuration?

Is there a way to include a different Javascript file in an ASP.NET page depending whether it's a debug or release build?

For release builds, I want to include the minified (using yuicompressor) Javascript, but I would like to use the more readable file for debug and development.

You can do one of two things ... either rename the appropriate file to the filename referenced in the html in a postbuild step, or dynamically include the html based on the preprocessor symbol.

For development, if you're using Visual Studio 2008 SP1 you can also take advantage of the improved support for JavaScript IntelliSense. Scott Gu has a blog post here:

jQuery Intellisense in VS2008

The basic set up is:

  1. Install Hotfix KB958502
  2. Reference release versions of your .js files as you would normally
  3. Ensure that you have the "development" version of the .js file sitting next to it, called *-vs-doc.js or *.debug.js

This will get you all the intellisense for the files.