无法在 Visual Studio 中将 Ajax Minifier 作为构建后运行
我已经设置了构建后配置,如 http://www.asp.net/ajaxlibrary 所示/ajaxminquickstart.ashx
但我收到以下错误:
“AjaxMin”任务不支持“JsSourceFiles”参数。 验证任务上存在该参数,并且它是可设置的公共实例属性。
我的配置设置......
<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>
我用反射器查看了 AjaxMinTask.dll,并注意到公开暴露的属性不与我的配置中的相匹配。不过,有一个名为 SourceFiles
的 ITaskItem
数组,因此我编辑了配置以匹配。
<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>
我现在收到错误:
“AjaxMin”任务不支持“SourceFiles”参数。 验证该参数存在于任务中,并且它是一个可设置的公共实例属性。
我现在正在摸不着头脑。当然应该比这更容易吗?
我在 Windows 7 64 位安装上运行 Visual Studio 2010 Ultimate。
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 by 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不建议在 AfterBuild 期间进行缩小。许多构建系统假设源代码在执行构建时是只读的和/或不变的,并且这将包括 .min.js 文件。
相反,您可以连接“CopyWebApplication”目标和 Visual Studio 2010 的网站部署引擎(WPP / Web 发布管道)来完成相同的操作,而无需 .min.js 文件。
看看我对这个问题的回答:
动态连接和缩小 JavaScript 或在构建时 - ASP.NET MVC
然而,要直接回答您的问题,“SourceFiles”属性不再存在。一些旧的博客文章没有更新,现在有旧的信息。尝试将“Js”放在属性前面 - 即/ JsSourceFiles="@(JS)"。
最新版本 - http://ajaxmin.codeplex.com/
文档 - http://ajaxmin.codeplex.com/wikipage?title=AjaxMinTask
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