问题描述
基本上,我的最终目标是消除建立我的Visual Studio解决方案的时候,而我的(版本4.20)为的MSBuild 之一任务,minifies的.js和.css文件。
据阿贾克斯Minifier文件,我可以使用 -clobber
选项来实现上述目标。不过,我无法揣摩出在Visual Studio MSBuild项目的任务,我可以使用此选项。我能够成功,虽然用从阿贾克斯Minifier命令行工具的 -clobber
选项。
下面是配置code,我已经在我的项目(.csproj的)文件...
<导入项目=$(MSBuildExtensionsPath)\微软\ MicrosoftAjax \ ajaxmin.tasks/>
<目标名称=AfterBuild>
< ItemGroup>
< JS包括=** \ * JS。排除=** \ * min.js;脚本\ * JS。/>
< / ItemGroup>
< ItemGroup>
< CSS包括=。** \ * CSS排除=** \ * min.css。/>
< / ItemGroup>
<min.js。AjaxMin JsSourceFiles =@(JS)JsSourceExtensionPattern =\ JS $JsTargetExtension = CssSourceFiles =@(CSS)CssSourceExtensionPattern =\ CSS $CssTargetExtension =min.css 揍=真/>
< /目标>
然而,当我编译我的解决方案,我得到了下面的错误 - 不知道为什么
您只需要通过在 -clobber
切换正确。
修改
<JS \ $AjaxMin JsSourceFiles =@(JS)JsSourceExtensionPattern = JsTargetExtension =。min.js
CssSourceFiles =@(CSS)CssSourceExtensionPattern =\ CSS $。CssTargetExtension =。min.css
揍=真/>
到
<JS \ $AjaxMin JsSourceFiles =@(JS)JsSourceExtensionPattern = JsTargetExtension =。min.js
CssSourceFiles =@(CSS)CssSourceExtensionPattern =\ CSS $。CssTargetExtension =。min.css
开关= - 撞/>
Basically, my end goal is to remove already present .min.js and CSS files when building my Visual Studio solution while I have Ajax Minifier (version 4.20) as one of MSBuild task which minifies .js and .css files.
According to Ajax Minifier documentation, I could use the -clobber
option to achieve the above mentioned goal. However, I'm not able to figure out where in Visual Studio MSBuild project task I can use this option. I'm successfully able to use the -clobber
option from Ajax Minifier command-line tool though.
Here is the configuration code which I have in my project (.csproj) file...
<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" clobber="true" />
</Target>
However, when I compiled my solution, I got following error - not sure why?
You just need to pass in the -clobber
switch correctly.
Change
<AjaxMin JsSourceFiles="@(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js"
CssSourceFiles="@(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css"
clobber="true" />
to
<AjaxMin JsSourceFiles="@(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js"
CssSourceFiles="@(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css"
Switches="-clobber" />
这篇关于如何在使用的Ajax Minifier使用-clobber选项的MSBuild过程在Visual Studio 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!