YUI Compressor for .Net

时间:2009-06-03 16:46:20

标签: msbuild yui yui-compressor

我正在尝试在MSbuild中使用YIUCompression DLL(http://yuicompressor.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22364)  但是当我运行MSBuild时,我一直收到以下错误:

输出:

  

目标构建:
      启动Css / Javascript压缩...

# Found one or more JavaScript file arguments. Now parsing ...
    ** Obfuscate Javascript: Yep!
    ** Preserve semi colons: Yep!
    ** Disable optimizations: Hell No!
    ** Line break position: None
    ** Thread Culture: Not defined
# 1 JavaScript file requested.
    => C:\JSMinify\YIUCompressor\Test\disableButton.js    C:\JSMinify\YIUCompressor\Millena-I.Build.proj(17,5): error : Failed to read in the data for the path/file [C:\JSMinify\YIUCompressor\Test\disableButton.js]. The most common cause for this is because the path is incorrect or the file name is incorrect ... so please check your path and file names. Until you fix this up, I can't continue ... sowwy.
C:\JSMinify\YIUCompressor\Millena-I.Build.proj(17,5): error : Value cannot be null.
C:\JSMinify\YIUCompressor\Millena-I.Build.proj(17,5): error : Parameter name: value
    Finished compressing all 1 file.
Total original JavaScript file size: 405. After compression: 0. Compressed down to 0% of original size.
Compressed content saved to file [C:\JSMinify\YIUCompressor\Test\disableButton.js].
Finished Css/Javascript compression.
Total time to execute task: 00:00:00.0312510
  

在项目“Millena-I.Build.proj”中完成构建目标“Build”。

     

完成建筑项目“Millena-I.Build.proj”。

     

构建成功。   C:\ JSMinify \ YIUCompressor \ Millena-I.Build.proj(17,5):错误:无法读取路径/文件的数据[C:\ JSMinify \ YIUCompressor \ Test \ disableButton.js]。最常见的原因是路径不正确或文件名不正确...所以请检查您的路径和文件名。在你解决这个问题之前,我无法继续... sowwy.C:\ JSMinify \ YIUCompressor \ Millena-I.Build.proj(17,5):错误:值不能为空。   C:\ JSMinify \ YIUCompressor \ Millena-I.Build.proj(17,5):错误:参数名称:值

以下是我的构建脚本:

                      

<!-- Execute CompressorTask for each file in the list -->
<CompressorTask
   Condition="'%(JavaScriptFiles.Identity)' != ''"
   JavaScriptFiles="%(JavaScriptFiles.Identity)"
   ObfuscateJavaScript="FoSho"
   PreserveAllSemicolons="Yeah"
   DisableOptimizations="Nope"
   EncodingType="Default"
   DeleteJavaScriptFiles="true"
   JavaScriptOutputFile="%(JavaScriptFiles.Identity)"
   LoggingType="ALittleBit" />

我已经给予文件夹和文件(删除只读)的完全权限。令人惊讶的是,当构建失败时,我的文件完全空白!

1 个答案:

答案 0 :(得分:1)

我在上一个ASP.NET项目中使用了java版的YUICompressor。 它对你有用吗,或者你只是对.dll文件感兴趣? 以下是我的目标任务。

<Target Name="MinifyScripts" Condition="Exists('$(JAVA_HOME)')">        
    <YuiCompress Files="@(JavaScriptContent)" Type="JS" JavaHome="$(JAVA_HOME)" YUIHome="$(MSBuildStartupDirectory)\Resource\BuildTool\yuicompressor-2.4.1.jar" />
    <YuiCompress Files="@(CssContent)" Type="CSS" JavaHome="$(JAVA_HOME)" YUIHome="$(MSBuildStartupDirectory)\Resource\BuildTool\yuicompressor-2.4.1.jar" />
</Target>

这真的很简单。尝试使用它。

Dave Ward在这里写了一篇关于这个主题的好文章:

Automatically minify and combine JavaScript in Visual Studio