asp.netvisual-sourcesafeweb-setup-projectmicrosoft-ajax-minifier

Using the Microsoft Ajax Minifier with Web Setup project & Source Control


I've just started investigating the Microsoft Ajax Minifer 4.0 for use with a Visual Studio 2008 Web Application I work on. It's proven easy enough to hook it into the .csproj file so it produced .min.js files for all scripts, however I'm stumped as to how to integrate this with the Web Setup project & Source Control.

Essentially what I want to do is have the resultant .min.js files included in the Web Setup project without having them included in Source Control because:

  1. Having to check them out prior to the build being executing is a pain (the minifier cannot modify them if they're not checked out).
  2. As they're created as a "build artifact" it just seems wrong to have them stored under source control.

The only option I've managed to come across so far is to explicitly include the .min.js files as part of the Setup project by right clicking on the Web Setup project and choosing "Add > File", and then having the relevant folder hierarchy duplicated in "File System on Target Machine" so that I can force the file to the correct location. This is neither elegant or simple/robust as:

  1. It requires me to manually add every minified js file to the Web Setup project by hand
  2. Maintain a copy of the relevant directory structure in both the Web Application project and the Web Setup project
  3. Remember to add any new js files minified versions to the Web Setup project

Is there a better way of doing this?


Solution

  • The solution I eventually opted for was to include the minifier DLL in my project and create a handler (.ashx) that I've replaced all references to .js files with, so:

    <script src="MyJsFile.js" type="text/javascript"></script>
    

    Is replaced with

    <script src="Minifier.ashx?file=MyJsFile.js" type="text/javascript"></script>
    

    I have a configuration setting in my web.config file that allows me to determine whether script files are minifed or not.