Setting Visual Studio to automatically minifying using Ajax Minifier

后端 未结 2 843
我在风中等你
我在风中等你 2021-01-27 14:28

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

相关标签:
2条回答
  • 2021-01-27 14:54

    On my project file I used "UsingTask" instead of "Import" and it's working:

    <UsingTask TaskName="AjaxMin" AssemblyFile="$(MSBuildProjectDirectory)\..\..\packages\AjaxMin.5.14.5506.26202\tools\net40\AjaxMinTask.dll" />
    	<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>

    0 讨论(0)
  • 2021-01-27 14:56

    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>
    
    0 讨论(0)
提交回复
热议问题