I use Asp.net 4 C# and MicrosoftAjax Minifier.
我使用Asp.net 4 c#和MicrosoftAjax Minifier。
Please look at my code here; Using <Target Name="AfterBuild">
I'm able to minify all files .js
and .css
. The problem is that this code minify even the original files in my project solution, so would be almost impossible to edit theme once again.
请看我的代码;使用
I need instead minify all .js
and .css
on my solution after publishing it to a local folder.
我需要在将其发布到本地文件夹后,将解决方案中的所有.js和.css缩小。
In this way I can keep my original files in my project folder intact and have instead the site compiled and minified into another local folder.
这样,我就可以在项目文件夹中保存我的原始文件,并将站点编译并缩小到另一个本地文件夹中。
I change my scripting using <Target Name="Publish">
, I do not receive any error but It does not work.
我使用
Could you tell me what I'm missing here, and if there is a better approach to solve this problem? Thanks
你能告诉我这里缺了什么吗?如果有更好的办法来解决这个问题的话?谢谢
<!-- Minify all JavaScript files that were embedded as resources -->
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="Publish">
<ItemGroup>
<JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
</ItemGroup>
<ItemGroup>
<CSS Include="**\*.css" Exclude="**\*.min.css" />
</ItemGroup>
<AjaxMin
JsSourceFiles="@(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".js"
CssSourceFiles="@(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".css" />
</Target>
1 个解决方案
#1
3
(copied from questions)
(抄袭问题)
To deal with losing the original js/css files, ensure the target filenames include .min, eg. JsTargetExtension=".min.js"
and CssTargetExtension=".min.css"
. See article on using MsAjax minifier: http://www.asp.net/ajaxlibrary/ajaxminquickstart.ashx
要处理丢失原始js/css文件的问题,请确保目标文件名包含.min,例如。JsTargetExtension = " .min。js”和CssTargetExtension = " .min.css”。请参阅有关使用MsAjax minifier的文章:http://www.asp.net/ajaxlibrary/ajaxminquickstart.ashx。
To then be able to publish the minified files, see this article: Using Microsoft AJAX Minifier with Visual Studio 2010 1-click publish
要发布缩小的文件,请参阅本文:使用Microsoft AJAX缩小器和Visual Studio 2010 1-click publish
At my workplace, we are solving the minifying issue quite differently by using Chirpy addin for Visual Studio. It automatically minifies files to a .min version upon saving. See http://chirpy.codeplex.com/
在我的工作场所,我们通过在Visual Studio中使用Chirpy addin来解决缩小的问题。它在保存时自动将文件缩小到.min版本。参见http://chirpy.codeplex.com/
#1
3
(copied from questions)
(抄袭问题)
To deal with losing the original js/css files, ensure the target filenames include .min, eg. JsTargetExtension=".min.js"
and CssTargetExtension=".min.css"
. See article on using MsAjax minifier: http://www.asp.net/ajaxlibrary/ajaxminquickstart.ashx
要处理丢失原始js/css文件的问题,请确保目标文件名包含.min,例如。JsTargetExtension = " .min。js”和CssTargetExtension = " .min.css”。请参阅有关使用MsAjax minifier的文章:http://www.asp.net/ajaxlibrary/ajaxminquickstart.ashx。
To then be able to publish the minified files, see this article: Using Microsoft AJAX Minifier with Visual Studio 2010 1-click publish
要发布缩小的文件,请参阅本文:使用Microsoft AJAX缩小器和Visual Studio 2010 1-click publish
At my workplace, we are solving the minifying issue quite differently by using Chirpy addin for Visual Studio. It automatically minifies files to a .min version upon saving. See http://chirpy.codeplex.com/
在我的工作场所,我们通过在Visual Studio中使用Chirpy addin来解决缩小的问题。它在保存时自动将文件缩小到.min版本。参见http://chirpy.codeplex.com/