views:

33

answers:

2

I am currently using Visual Studio 2010 post-build event to minify my JavaScript files. The problem is every time I add a new JavaScript file I have to update the post build event. What I want to do is make the script a bit more flexible.

Directory structure:

\Scripts\

  • Script1.debug.js
  • Script2.debug.js
  • Script3.debug.js

Here is my script's current state:

ajaxmin.exe "$(ProjectDir)Scripts\Script1.debug.js" -out "$(ProjectDir)Scripts\Script1.js" -clobber
ajaxmin.exe "$(ProjectDir)Scripts\Script2.debug.js" -out "$(ProjectDir)Scripts\Script2.js" -clobber
ajaxmin.exe "$(ProjectDir)Scripts\Script3.debug.js" -out "$(ProjectDir)Scripts\Script3.js" -clobber

I want this script to find every *.debug.js file minify it and output it to *.js. How do I achieve this?

Script1.debug.js --> Script1.js
Script2.debug.js --> Script2.js
Script3.debug.js --> Script3.js

A: 

Create a batch script file to do the task and call the batch file from your PostBuild event.

Sheen
Sheen, this script is already in a batch file. I just need to know how to write the script required to solve the problem described. It isn't a matter of where the script will live (batch or build event textbox).
sgmeyer
+1  A: 

Don't use a post build event. After installing the tool, an MSBuild task was added that runs the minifier automatically for a .js file in your project. You need a bit of minor surgery to the project file. The details are explained in this blog post.

Hans Passant
This is exactly what I was looking for!! Thank you.
sgmeyer