title: Using Microsoft AJAX Minifier with Visual Studio 2010 1-click publish
body: <p>The <a href="http://aspnet.codeplex.com/releases/view/40584" rel="noreferrer">Microsoft AJAX Minifier</a> provides a <a href="http://www.asp.net/ajaxlibrary/AjaxMinTask.ashx" rel="noreferrer">build task</a> which can be used in TFS or local build definitions.</p>
  
  <p>I have succsfully used this in both a local project file (building to seperate files) and in TFS build definitions (overwriting the existing JS files).</p>
  
  <p>I'd like to move to using Visual Studio 2010's 1-click publish feature rather than a TFS build definition, however adding the minification task as an AfterBuild target in the project file doesn't appear to effect the 1-click publish feature.</p>
  
  <p>Using information found in <a href="http://forums.iis.net/t/1168227.aspx" rel="noreferrer">this thread</a> and <a href="http://blogs.msdn.com/b/webdevtools/archive/2010/02/09/how-to-extend-target-file-to-include-registry-settings-for-web-project-package.aspx" rel="noreferrer">these</a> <a href="http://leethams.wordpress.com/2010/06/12/modifying-directory-permissions-with-web-deployment/" rel="noreferrer">articles</a>, I tried creating a file named '[ProjectName].wpp.targets in my WAP root directory, and used the following XML:</p>
  
  <pre><code>&lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  &lt;Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" /&gt;
  &lt;Target Name="Minify" BeforeTargets="MSDeployPublish"&gt;
      &lt;ItemGroup&gt;
        &lt;JS Include="**\*.js" Exclude="**\*.min.js;**\*vsddoc.js;**\*debug.js" /&gt;
      &lt;/ItemGroup&gt;
      &lt;ItemGroup&gt;
        &lt;CSS Include="**\*.css" Exclude="**\*.min.css" /&gt;
      &lt;/ItemGroup&gt;
      &lt;AjaxMin JsSourceFiles="@(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js" CssSourceFiles="@(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" /&gt;
    &lt;/Target&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>This doesn't appear to have any effect, and unfortunately Visual Studio doesn't give much in the way of feedback or debugging info for these tools.</p>
  
  <p>Has anyone had any success minifying JavaScript / CSS using the Visual Studio 2010 1-click publish feature?</p>