Script Minification and Continuous Integration with MSBuild Script Minification and Continuous Integration with MSBuild javascript javascript

Script Minification and Continuous Integration with MSBuild


The MSBuildCommunityTasks Project has a few MSBuild tasks that may do what you are looking for including Merge and JSCompress.

You could add these into your MSBuild project in the AfterBuild target to allow the project to perform this action every time the project is built and nothing would ever be out of sync. Your web application could then reference the compacted version for run but the developers would edit the full versions.

Nothing else would be needed on the server except the MSBuild community tasks assembly. You can put this assembly in your own source tree and reference from there and your CI build should get that assembly and everything it needs when it builds.


Not a perfect answer, but if you're using MVC4 they've built this in as a new feature. When running a Debug configuration, it outputs individual files with comments and such but when you switch to Release, it will automatically bundle, minify, and change in page references to the minified files. You can setup separate bundles for, say, jquery and your own js. This works with CSS and JS files.

http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification

If MVC4 doesn't work for you, you can also find packages on Nuget that can help such as this:

https://www.nuget.org/packages?q=minify