Erorr The "CompressorTask" task could not be loaded from the assembly

Mar 1, 2012 at 8:53 AM

Hi all,

I have downloaded version 1.7.0.0 from CodePlex but when I run my build process using this I get the following error.

C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(270,5): error MSB4062: The "CompressorTask" task could not be loaded from the assembly C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..\Lib\Minification\Yahoo.Yui.Compressor.dll. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

The relevant sections of my build file are below

  <UsingTask TaskName="CompressorTask" AssemblyFile="C:\Projects\AC3UserInterface\MCFC\lib\Minification\Yahoo.Yui.Compressor.dll" />

  <PropertyGroup>
    <CssOutputFile Condition=" '$(CssOutputFile)'=='' ">
      ../src/UserInterface/Content/css/Minified.css
    </CssOutputFile>
    <JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">
      ../src/UserInterface/Content/js/Minified.js
    </JavaScriptOutputFile>
  </PropertyGroup>

 

<Target Name="Minify">

    <ItemGroup>
      <CssFiles Include="../src/UserInterface/Content/css/styles.css" />
        <CssFiles Include="../src/UserInterface/Content/css/mcfcStyle.css" />
          <CssFiles Include="../src/UserInterface/Content/js/fancybox/jquery.fancybox-1.3.4.css"/>
            <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery-1.6.4.min.js"/>
              <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.cycle.all.latest.min.js"/>
                <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.countdown.min.js"/>
                  <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.carouFredSel-5.5.0-packed.js"/>
                    <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.tipsy.js"/>
                      <JavaScriptFiles Include="..src/UserInterface/Scripts/script.js"/>
                        <JavaScriptFiles Include="..src/UserInterface/Content/js/fancybox/jquery.fancybox-1.3.4.pack.js"/>
    </ItemGroup>

    <CompressorTask CssFiles="@(CssFiles)" DeleteCssFiles="false" CssOutputFile="$(CssOutputFile)"
                    CssCompressionType="YuiStockCompression" JavaScriptFiles="@(JavaScriptFiles)"
                    ObfuscateJavaScript="True" PreserveAllSemicolons="False" DisableOptimizations="Nope"
                    EncodingType="Default" DeleteJavascriptFiles="false" LineBreakPosition="-1"
                    JavaScriptOutputFile="$(JavaScriptOutputFile)" LoggingType="ALittleBit"
                    ThreadCulture="en-CA" IsEvalIgnored="false">
    </CompressorTask>
  </Target>

 

And of course I have called the Minify target as a dependancy of another target.  Also, the folder C:\Projects\AC3UserInterface\MCFC\lib\Minification contains EcmaScript.NET.modified.dll, Yahoo.Yui.Compressor.dll and Yahoo.Yui.Compressor.MsBuildTask.dll.

Why do I get this error?

Thanks,

Sachin

Coordinator
Mar 1, 2012 at 9:00 AM

Hello, 

From the output you have provided:

The "CompressorTask" task could not be loaded from the assembly C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..\Lib\Minification\Yahoo.Yui.Compressor.dll

but you say your using statement says:

  <UsingTask TaskName="CompressorTask" AssemblyFile="C:\Projects\AC3UserInterface\MCFC\lib\Minification\Yahoo.Yui.Compressor.dll" />

Looks like you are looking in two different places.....

Mar 1, 2012 at 10:58 AM
Edited Mar 1, 2012 at 11:02 AM

I've now made sure of the path's and they do exist.

Here's the error with correct paths

"C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml" (Deploy target) (1) ->
(Minify target) -> 
  C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(269,5): error MSB4062: 
The "CompressorTask" task could not be loaded from the assembly
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..\Lib\Minification\Yahoo.Yui.Compressor.dll.
Confirm that the <UsingTask> declaration is correct, that the assembly and
all its dependencies are available, and that the task contains a public class
that implements Microsoft.Build.Framework.ITask.


And here are the sections of my main.xml file.

  <UsingTask TaskName="CompressorTask" AssemblyFile="..\Lib\Minification\Yahoo.Yui.Compressor.dll" />

  <PropertyGroup>
    <CssOutputFile Condition=" '$(CssOutputFile)'=='' ">
      ../src/UserInterface/Content/css/Minified.css
    </CssOutputFile>
    <JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">
      ../src/UserInterface/Content/js/Minified.js
    </JavaScriptOutputFile>
  </PropertyGroup>

  <Target Name="Minify">
    <ItemGroup>
      <CssFiles Include="../src/UserInterface/Content/css/styles.css" />
        <CssFiles Include="../src/UserInterface/Content/css/mcfcStyle.css" />
          <CssFiles Include="../src/UserInterface/Content/js/fancybox/jquery.fancybox-1.3.4.css"/>
            <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery-1.6.4.min.js"/>
              <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.cycle.all.latest.min.js"/>
                <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.countdown.min.js"/>
                  <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.carouFredSel-5.5.0-packed.js"/>
                    <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.tipsy.js"/>
                      <JavaScriptFiles Include="..src/UserInterface/Scripts/script.js"/>
                        <JavaScriptFiles Include="..src/UserInterface/Content/js/fancybox/jquery.fancybox-1.3.4.pack.js"/>
    </ItemGroup>

    <CompressorTask CssFiles="@(CssFiles)" DeleteCssFiles="false" CssOutputFile="$(CssOutputFile)"
                    CssCompressionType="YuiStockCompression" JavaScriptFiles="@(JavaScriptFiles)"
                    ObfuscateJavaScript="True" PreserveAllSemicolons="False" DisableOptimizations="Nope"
                    EncodingType="Default" DeleteJavascriptFiles="false" LineBreakPosition="-1"
                    JavaScriptOutputFile="$(JavaScriptOutputFile)" LoggingType="ALittleBit"
                    ThreadCulture="en-CA" IsEvalIgnored="false">
    </CompressorTask>
  </Target>
 
Mar 1, 2012 at 11:14 AM

I seem to have figured out the issue.  Instead of using Yahoo.Yui.Compressor.dll you need to use Yahoo.Yui.Compressor.MsBuildTask.dll for some reason.

Now I have another issue.  I have this setup

<PropertyGroup>
    <CssOutputFile Condition=" '$(CssOutputFile)'=='' ">
      C:\Minified.css
    </CssOutputFile>
    <JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">
      C:\Minified.js
    </JavaScriptOutputFile>
  </PropertyGroup>

And get this error

C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(269,5): error : Failed to save the compressed text into the output file [
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(269,5): error :       C:\Minified.css
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(269,5): error :     ]. Please check the path/file name and make sure the file isn't magically locked, read-only, etc..
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(269,5): error : Illegal characters in path.
Done Building Project "C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml" (Deploy target(s)) -- FAILED.

Build FAILED.

"C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml" (Deploy target) (1) ->
(Minify target) -> 
  C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(269,5): error : Failed to save the compressed text into the output file [
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(269,5): error :       C:\Minified.css
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(269,5): error :     ]. Please check the path/file name and make sure the file isn't magically locked, read-only, etc..
  C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(269,5): error : Illegal characters in path.

    0 Warning(s)
    2 Error(s)
Coordinator
Mar 1, 2012 at 11:50 AM

Try using a propertygroup like this:

<PropertyGroup>
    <CssOutputFile Condition=" '$(CssOutputFile)'=='' ">C:\Minified.css</CssOutputFile>
    <JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">C:\Minified.js</JavaScriptOutputFile>
  </PropertyGroup>
ie, with no leading/trailing spaces - it may be the compressor needs a cunning Trim() added when it checks the path

Mar 1, 2012 at 1:46 PM

Thanks that was spot on. :-)

I have another error now.  On the build server my output css file is empty and my js file is non-existant.

Here's the script

<ItemGroup>
      <CssFiles Include="../src/UserInterface/Content/css/styles.css" />
        <CssFiles Include="../src/UserInterface/Content/css/mcfcStyle.css" />
          <CssFiles Include="../src/UserInterface/Content/js/fancybox/jquery.fancybox-1.3.4.css"/>
            <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery-1.6.4.min.js"/>
              <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.cycle.all.latest.min.js"/>
                <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.countdown.min.js"/>
                  <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.carouFredSel-5.5.0-packed.js"/>
                    <JavaScriptFiles Include="..src/UserInterface/Scripts/jquery.tipsy.js"/>
                      <JavaScriptFiles Include="..src/UserInterface/Scripts/script.js"/>
                        <JavaScriptFiles Include="..src/UserInterface/Content/js/fancybox/jquery.fancybox-1.3.4.pack.js"/>
    </ItemGroup>

And here's the output

Minification started
  Starting Css/Javascript compression...
  Using version 1.7.0.0 of YUI Compressor .NET Library MsBuild Task.
  Current thread culture / UI culture (before modifying, if requested): English (United Kingdom)/English (United States)
  
  # Found one or more css file arguments. Now parsing ...
  # 3 css files requested.
      => ../src/UserInterface/Content/css/styles.css
      => ../src/UserInterface/Content/css/mcfcStyle.css
      => ../src/UserInterface/Content/js/fancybox/jquery.fancybox-1.3.4.css
      Finished compressing all 3 files.
  Total original css file size: 50233. After compression: 42270. Compressed down to 84.14787% of original size.
  Css Compression Type: Stock YUI compression.
  Compressed content saved to file [../src/UserInterface/Content/css/Minified.css].
  
  # Found one or more JavaScript file arguments. Now parsing ...
      ** Obfuscate Javascript: Yep!
      ** Preserve semi colons: Nope :(
      ** Disable optimizations: Hell No!
      ** Line break position: None
      ** Thread Culture: English (Canada)
  # 7 JavaScript files requested.
      => ..src/UserInterface/Scripts/jquery-1.6.4.min.js
      => ..src/UserInterface/Scripts/jquery.cycle.all.latest.min.js
      => ..src/UserInterface/Scripts/jquery.countdown.min.js
      => ..src/UserInterface/Scripts/jquery.carouFredSel-5.5.0-packed.js
      => ..src/UserInterface/Scripts/jquery.tipsy.js
      => ..src/UserInterface/Scripts/script.js
      => ..src/UserInterface/Content/js/fancybox/jquery.fancybox-1.3.4.pack.js
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Failed to read in the data for the path/file [..src/UserInterface/Scripts/jquery-1.6.4.min.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:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Could not find a part of the path 'C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..src\UserInterface\Scripts\jquery-1.6.4.min.js'.
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Failed to read in the data for the path/file [..src/UserInterface/Scripts/jquery.cycle.all.latest.min.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:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Could not find a part of the path 'C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..src\UserInterface\Scripts\jquery.cycle.all.latest.min.js'.
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Failed to read in the data for the path/file [..src/UserInterface/Scripts/jquery.countdown.min.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:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Could not find a part of the path 'C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..src\UserInterface\Scripts\jquery.countdown.min.js'.
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Failed to read in the data for the path/file [..src/UserInterface/Scripts/jquery.carouFredSel-5.5.0-packed.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:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Could not find a part of the path 'C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..src\UserInterface\Scripts\jquery.carouFredSel-5.5.0-packed.js'.
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Failed to read in the data for the path/file [..src/UserInterface/Scripts/jquery.tipsy.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:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Could not find a part of the path 'C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..src\UserInterface\Scripts\jquery.tipsy.js'.
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Failed to read in the data for the path/file [..src/UserInterface/Scripts/script.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:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Could not find a part of the path 'C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..src\UserInterface\Scripts\script.js'.
C:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Failed to read in the data for the path/file [..src/UserInterface/Content/js/fancybox/jquery.fancybox-1.3.4.pack.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:\Builds\Mcfc\UI\Latest\MCFC\scripts\main.xml(265,5): error : Could not find a part of the path 'C:\Builds\Mcfc\UI\Latest\MCFC\scripts\..src\UserInterface\Content\js\fancybox\jquery.fancybox-1.3.4.pack.js'.
      Finished compressing all 7 files.
  Total original JavaScript file size: 0. After compression: 0. Compressed down to NaN% of original size.
  Compressed content saved to file [../src/UserInterface/Content/css/Minified.css].
  
  Finished Css/Javascript compression.
  Reverted back to thread culture / UI culture: English (United Kingdom)/English (United States)
  Total time to execute task: 00:00:00.6609375
  8< ---------------------------------  ( o Y o )  --------------------------------- >8
  
  Minification ended
Coordinator
Mar 1, 2012 at 2:04 PM

Hi,

you are specifying your file locations as "..src" which is not a valid path - you probably want something like "..\src" (or "../src" if you prefer unix style notation).

Also, I see you are compressing a lot of .min files, which are already compressed.  You should just store those instead of trying to re-compress them.

eg:

 

<JavaScriptFiles Include="../src/UserInterface/Scripts/jquery-1.6.4.min.js">
    <CompressionType>None</CompressionType>
</JavaScriptFiles >   

 

and switch to the invariant culture while you're at it for good measure - add

ThreadCulture="iv"

 to the CompressorTask call in your build script

 


Mar 1, 2012 at 2:32 PM

Thanks.  You can see I'm totally new to this.  This all helped.  I have done all you suggested. 

There may be further errors but at the moment the build at least succeeds.

A question about something I saw in the output:

** Preserve semi colons: Nope :(

Isn't it a good idea to preserve semi colons?
Coordinator
Mar 1, 2012 at 2:45 PM

Phew, we got there!

Is it a good idea to preserve semicolons?  That depends - if you have too many of them then no.

e.g;

 

var foo;;

 

becomes

var foo;

and

 

if (foo == bar) {
// stuff
};

 

becomes

if (foo == bar) {
// stuff
}
Both work, but the extra semi colons are just not necessary....

Coordinator
Mar 1, 2012 at 11:26 PM

Epic!