Ajax Minifier: JS file duplication when combining via project file / msbuild task
===

I've been attempting to get minification and bundling working on my MVC3 project for some time, trying out quite a few different compressors and methods. I've finally settled on using Microsoft Ajax Minifier via an msbuild task in my project file. I'm only so far in to my configuration, but I've hit an immediate stumbling block; when I minify and combine my JS scripts in to a single file (using the task definition below), my combined file always contains two minified copies of each script.

I've cut out all other complicated msbuild tasks I've added, removed all but one JS script, and it's still happening. The below tags are the only part of my project file that I have manually modified:

    <UsingTask TaskName="AjaxMin" AssemblyFile="$(MSBuildProjectDirectory)\..\_Build\AjaxMinTask.dll" />
    <Target Name="AfterBuild">
    	<ItemGroup>
    		<JsFiles Include="**\res\js\libs\jquery.js" />
    	</ItemGroup>
    	<AjaxMin Switches="-global:jQuery,$" JsSourceFiles="@(JsFiles)" JsCombinedFileName="Combined.min.js" />
    </Target>

Combined.min.js is created in the root of my web project (as expected), but it contains two minified copies of the jquery.js file.

I'm using Microsoft Visual Studio Ultimate 2012 RC (Version 11.0.50706.0 QRELRC July, 2012) and the references "AjaxMinTask.dll" file is the latest version (4.59.4576.13505) from [here][1].

Now, here's the weirdest thing. Additionally, I have created completely new MVC3 projects in both VS 2010 and VS 2012, and copied & pasted the above lines in to their project files - only changing the path to AjaxMinTask.dll (to use the same as the broken project) and the path to the JQuery file (\scripts\jquery.<version>.js), and ***they work perfectly fine***.

Unfortunately I can't paste the project file as it's too long for stack overflow, so I've zipped it up with the original jquery file I'm trying to minify / combine, the resulting "minified" file, and the AjaxMin assemblies I'm using:

[http://www.rustyshark.com/minification.zip][2]

Alternatively, I'm very open to any other suggested methods that will allow me to minify / combine when I build in release mode in Visual Studio 2012, using .Net 4.0 and MVC 3.


  [1]: http://ajaxmin.codeplex.com/releases/view/91030
  [2]: http://www.rustyshark.com/minification.zip