2009-06-03 98 views
2

我試圖使用YIUCompression DLL中的MSBuild(http://yuicompressor.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22364) ,但我一直在得到以下錯誤,當我運行的MSBuild:YUI壓縮機對於.NET

OUTPUT:

目標構建:
啓動的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」中完成建築目標「構建」。

完成建築項目「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):error:值不能爲空。 C:\ JSMinify \ YIUCompressor \米列納-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

我已經爲我最後一個ASP.NET項目使用了YUICompressor的java版本。 它是否適合您,或者您只對.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> 

這真的很簡單。嘗試使用它。

達沃·沃德寫了一篇關於這個話題口碑不錯的文章:

Automatically minify and combine JavaScript in Visual Studio