I use Asp.net 4 C# and 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.
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>