Setting Visual Studio to automatically minifying using Ajax Minifier

拈花ヽ惹草 提交于 2019-12-13 05:20:26

问题


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>

回答1:


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>



回答2:


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>


来源:https://stackoverflow.com/questions/7675567/setting-visual-studio-to-automatically-minifying-using-ajax-minifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!