visual-studio-2010minifymicrosoft-ajax-minifier

Setting Visual Studio to automatically minifying using Ajax Minifier


I use VS 2010 I would like at the pressing of Build Button have all CSS and .JS files minified.

Following this article all is working great for JS... adding some extra code for the CSS (pasted below) I'm not able to Minifying the CSS. What I'm doing wrong here?

Thanks for your time.

   <Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="AfterBuild">
<ItemGroup>
    <JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
    <JS Include="**\*.css" Exclude="**\*.min.css;Scripts\*.css" />
</ItemGroup>
    <AjaxMin SourceFiles="@(JS)" SourceExtensionPattern="\.js$" TargetExtension=".min.js" />
    <AjaxMin SourceFiles="@(CSS)" SourceExtensionPattern="\.css$" TargetExtension=".min.css" />
</Target>

Solution

  • I found out the solution to my problem, more resource here

    Unable to run Ajax Minifier as post-build in Visual Studio

    http://ajaxmin.codeplex.com/wikipage?title=AjaxMinTask

    Also very interesting: http://www.codeproject.com/Articles/81317/Automatically-compress-embedded-JavaScript-resourc.aspx?msg=3802401&display=Mobile

    <Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
    <Target Name="AfterBuild">
        <ItemGroup>
            <JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
        </ItemGroup>
        <ItemGroup>
            <CSS Include="**\*.css" Exclude="**\*.min.css" />
        </ItemGroup>
        <AjaxMin
            JsSourceFiles="@(JS)"  JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js"
            CssSourceFiles="@(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css"  />
    </Target>