YUI compressor + ASP.NET + post build event + build errors

Mar 4, 2015 at 6:54 AM
Hi All,

I am trying to compress JS/CSS files once project is build successfully. I am using YUI compressor DLLs. I have gone through multiple examples (http://blackriver.to/2011/09/compressing-css-with-yui-compressor-for-net/ , https://peronnemyr.wordpress.com/code-samples/yuicompressor-for-net-full-example-of-settings-xml-for-version-2-0-0-0/) and tried to implement in my project but i am getting few build errors.


XML file :
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
<UsingTask TaskName="CssCompressorTask" AssemblyFile="Compressor\Yahoo.Yui.Compressor.MsBuildTask.dll" />
<UsingTask TaskName="JavaScriptCompressorTask" AssemblyFile="Compressor\Yahoo.Yui.Compressor.MsBuildTask.dll" />

<Target Name="Minify">
<ItemGroup>
  <CssFiles Include="css\123.css"/>
  <CssFiles Include="css\456.css"/>
  <!--<JavaScriptFiles Include="js\custom\Admin_Main.js"/>-->
</ItemGroup>

<CssCompressorTask
        SourceFiles="@(CssFiles)"
        DeleteSourceFiles="false"
        OutputFile="%(CssFiles.Identity).min"
        CompressionType="Standard"
        LoggingType="Info"
        PreserveComments="false"
        LineBreakPosition="-1"/>

<!--<JavaScriptCompressorTask
    SourceFiles="@(JavaScriptFiles)"
    DeleteSourceFiles="false"
    OutputFile="Minified.js"
    CompressionType="Standard"
    ObfuscateJavaScript="True"
    PreserveAllSemicolons="False"
    DisableOptimizations="No"
    EncodingType="Default"
    LineBreakPosition="-1"
    LoggingType="Info"
    ThreadCulture="en-au"
    IsEvalIgnored="false"/>-->
</Target>
</Project>

Post build event:
$(MSBuildBinPath)\msbuild.exe /p:Configuration=$(ConfigurationName) "$(ProjectDir)\BuildConfig.xml"

note : DLLs are added in folder(Compressor) in web project. XML file is placed at root level in web project.

Build errors are as follows :

1)The "CssCompressorTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Windows\Microsoft.NET\Framework\v2.0.50727"

2) The "CssCompressorTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Windows\Microsoft.NET\Framework\v2.0.50727"

3) The command "C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe /p:Configuration=Release "C:\XML PATH"" exited with code 1.
Coordinator
Mar 5, 2015 at 6:40 AM
Sounds like it's just not finding the dlls...maybe some of your paths are a bit wrong.
If you zip up and send over an entire project that fails (as minimal as possible, only enough to demonstrate the problem) then we can take a look for you
Dec 30, 2015 at 1:58 AM
i find a free online service to minify js and compress css , it's using YUI compressor.