I am playing with the Microsoft Ajax Minifier, which removes whitespace from your Javascripts for quicker download. Stephen Walther has a nice how-to.

In my case, I am using the MSBuild task, which will minimize your Javascripts on build. Works great on my machine. But here’s the gotcha: if you have a build server that does not have the Minifier installed, your build will fail.

What to do? In my case, I updated Stephen’s MSBuild code with a Condition such that the task will only run under the Debug configuration. Thus, if your build server uses the Release configuration (as it should), the task will be ignored and your build won’t fail.

Here’s Stephen’s original code: <Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" /><Target Name="AfterBuild"><ItemGroup><JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" /></ItemGroup><AjaxMin SourceFiles="@(JS)" SourceExtensionPattern="\.js$" TargetExtension=".min.js" /></Target>And here are my adjustments, note the Condition attributes:<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" **Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "** /><Target Name="AfterBuild" **Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "**><ItemGroup><JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" /></ItemGroup><AjaxMin SourceFiles="@(JS)" SourceExtensionPattern="\.js$" TargetExtension=".min.js" /></Target>Hope this helps!