无法在Visual Studio中将Ajax Minifier作为生成后运行 [英] Unable to run Ajax Minifier as post-build in Visual Studio

查看:123
本文介绍了无法在Visual Studio中将Ajax Minifier作为生成后运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照 http://www.asp所示进行了设置. net/ajaxlibrary/ajaxminquickstart.ashx

我遇到以下错误:

"AjaxMin"任务不支持"JsSourceFiles"参数. 验证参数是否存在于任务中,并且它是可设置的公共实例属性.

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.

我的配置设置...

<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,并注意到公开显示的属性与我的配置中的属性不匹配.虽然有一个名为SourceFilesITaskItem数组,所以我编辑了配置以匹配.

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>

我现在收到错误:

"AjaxMin"任务不支持"SourceFiles"参数. 验证参数是否存在于任务中,并且它是可设置的公共实例属性.

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?

我正在Windows 7 64位安装上运行Visual Studio 2010 Ultimate.

I'm running Visual Studio 2010 Ultimate on a Windows 7 64 bit installation.

推荐答案

我不建议在AfterBuild中缩小.许多构建系统都假设执行该构建时源代码是只读的和/或不变的,并且其中包括.min.js文件.

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.

相反,您可以连接到"CopyWebApplication"目标和Visual Studio 2010的网站部署引擎(WPP/Web发布管道),以完全不需要.min.js文件来完成同一任务.

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.

看看我对这个问题的回答: 动态或在构建时连接和最小化JavaScript-ASP.NET MVC

Have a look at my response on this question: Concatenate and minify JavaScript on the fly OR at build time - ASP.NET MVC

但是,要直接回答您的问题,"SourceFiles"属性不再存在.一些较旧的博客文章未更新,现在包含旧信息.尝试在属性前面放置"Js"-ie/JsSourceFiles ="@(JS)".

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)".

最新版本- http://ajaxmin.codeplex.com/

文档- http://ajaxmin.codeplex.com/wikipage?title=AjaxMinTask

这篇关于无法在Visual Studio中将Ajax Minifier作为生成后运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆