I am using the Yahoo.Yui.Compressor.Build.MsBuild to compress the css
and javascript
files. I have installed the Yahoo.Yui.Compressor.Build.MsBuild 2.2 and the format of xml file is
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
<UsingTask
TaskName="CompressorTask"
AssemblyFile="..\..\lib\yui\Yahoo.Yui.Compressor.Build.MsBuild.dll" />
<PropertyGroup>
<JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">..\scripts-min\myfile.min.js</JavaScriptOutputFile>
</PropertyGroup>
<Target Name="MyTaskTarget">
<ItemGroup>
<JavaScriptFiles Include="$(SourceLocation)..\scripts\myfile.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-au"
/>
</Target>
</Project>
when I build the code then it's shows the below error
Error 18 The "CompressorTask" task could not be loaded from the assembly D:\Projects\YUI\..\..\lib\yui\Yahoo.Yui.Compressor.Build.MsBuild.dll. Could not load file or assembly 'Yahoo.Yui.Compressor, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null'or one of its dependencies. The system cannot find the file specified. 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.
I just ran into the same issue...
It appears that Yahoo.Yui.Compressor.dll
needs to be in the same directory as Yahoo.Yui.Compressor.Build.MsBuild.dll
. The same is probably true for the other dependencies, such as EcmaScript.NET.dll and Iesi.Collections.dll.
You can either move things to your \lib\yui\ directory so that they sit alongside each other, or you can reference the assemblies in your bin folder.
If you decide to reference the assemblies in the bin folder, you may have to use a post-build event to trigger the compression, as opposed to a pre-build event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With