Unable to run Ajax Minifier as post-build in Visual Studio
I've set up my post build config as demonstrated at http://www.asp.net/ajaxlibrary/ajaxminquickstart.ashx
I'm getting the following error though:
The "JsSourceFiles" parameter is not supported b开发者_Go百科y the "AjaxMin" task. Verify the parameter exists on the task, and it is a settable public instance property.
My configuration settings......
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="AfterBuild">
<ItemGroup>
<JS Include="**\*.js" Exclude="**\*.min.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>
I had a look at the AjaxMinTask.dll with reflector and noted that the publicly exposed properties do not match the ones in my config. There is an array of ITaskItem
called SourceFiles
though so I edited my configuration to match.
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="AfterBuild">
<ItemGroup>
<JS Include="**\*.js" Exclude="**\*.min.js" />
</ItemGroup>
<ItemGroup>
<CSS Include="**\*.css" Exclude="**\*.min.css" />
</ItemGroup>
<AjaxMin
SourceFiles="@(JS);@(CSS)" SourceExtensionPattern="\.js$;\.css$" TargetExtension=".min.js;.min.css"/>
</Target>
I now get the error:
The "SourceFiles" parameter is not supported by the "AjaxMin" task. Verify the parameter exists on the task, and it is a settable public instance property.
I'm scratching my head now. Surely it should be easier than this?
I'm running Visual Studio 2010 Ultimate on a Windows 7 64 bit installation.
I wouldn't recommend minifying during AfterBuild. Many build systems make the assumption that the source code is readonly and/or unchanging when the build is being executed, and that would include the .min.js files.
Instead, you can hook into the "CopyWebApplication" target and Visual Studio 2010's website deployment engine (WPP / Web Publishing Pipeline) to accomplish the same thing without .min.js files at all.
Have a look at my response on this question: Concatenate and minify JavaScript on the fly OR at build time - ASP.NET MVC
To answer your question directly however, the "SourceFiles" property no longer exists. Some older blog posts weren't updated and now have the old information. Try placing "Js" in front of the properties - ie/ JsSourceFiles="@(JS)".
Latest version - http://ajaxmin.codeplex.com/
Documentation - http://ajaxmin.codeplex.com/wikipage?title=AjaxMinTask
精彩评论