VS2010

Aug 10, 2009 at 3:49 AM

I'm having problems getting VUI Compressor to work with VS2010. I have not used it before, so it could be somehing basic that I'm doing wrong. My MSBuild file (snippet) is:

<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
    <UsingTask
        TaskName="CompressorTask"
        AssemblyFile="..\..\..\Yahoo.Yui.Compressor\bin\Yahoo.Yui.Compressor.dll" /

<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
    <UsingTask
        TaskName="CompressorTask"
        AssemblyFile="..\..\..\Yahoo.Yui.Compressor\bin\Yahoo.Yui.Compressor.dll" />
... 
</Project>
 

My post event command line reads (obviously the XML file is being parsed):

$(MSBuildBinPath)\msbuild.exe "$(ProjectDir)MSBuild\MSBuild.xml"

The error messages read:

Error 1 The "CompressorTask" task could not be loaded from the assembly C:\Users\donavon\Documents\Visual Studio 10\Projects\jsBuild35\jsBuild35\MSBuild\..\..\..\Yahoo.Yui.Compressor\bin\Yahoo.Yui.Compressor.dll. Could not load file or assembly 'file:///C:\Users\donavon\Documents\Visual Studio 10\Projects\Yahoo.Yui.Compressor\bin\Yahoo.Yui.Compressor.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) 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. C:\Users\donavon\Documents\Visual Studio 10\Projects\jsBuild35\jsBuild35\MSBuild\MSBuild.xml 73 9 jsBuild35

Error 3 The command "C:\Windows\Microsoft.NET\Framework\v4.0.20506\msbuild.exe "C:\Users\donavon\Documents\Visual Studio 10\Projects\jsBuild35\jsBuild35\MSBuild\MSBuild.xml"" exited with code 1. jsBuild35

I have verified that C:\Users\donavon\Documents\Visual Studio 10\Projects\Yahoo.Yui.Compressor\bin\Yahoo.Yui.Compressor.dll is actually where the DLL (plus EcmaScript.NET.modified.dll) is placed. I also have a copy of both DLLs in the MSBuild folder under my project (there were instructions somewhere that said they belonged there). I have a C# Web Project using .NET 3.5. Note that error 3 references the v4.0.20506 folder.

Any help you could give would be appreciated.

Donavon

Coordinator
Aug 10, 2009 at 4:14 AM

Hi Donavon,

thanks for giving YUICompressor.NET a go :) Unfortunately, I don't have a copy of VS2010 and nor will I have any free time to give it a play, until after it's RTM'd. I'm going to have to wait and hope someone else from the interwebs can help out, instead.
It looks like the error message is about ... msbuild? Maybe try to use a full path to the location (eg. C:\Users\donavon\Documents\Visual Studio 10\Projects\Yahoo.Yui.Compressor\bin\Yahoo.Yui.Compressor.dll in the UsingTask section)

Sincerly sorry mate :(

Sep 16, 2011 at 9:50 AM

I have the same problem. Downloaded from Nuget today, didn't work, so also dloaded the Dll's direct from CodePlex.

Have dlls in MsBuild folder and the bin folder. XML has also been changed to full path....

I'll leave it for now and try again in a couple of days... had it working with the AjaxMin stuff, but wanted something to handle conditional comments, which I was hoping this would....

VS2010 against .net4

Error	2	The "CompressorTask" task could not be loaded from the assembly 
C:\Data\Websites\SOLNAME\PROJNAME\MsBuild\Yahoo.Yui.Compressor.dll.  Confirm that the  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.	

Sep 16, 2011 at 12:42 PM

I also have the same problem running this from commandline.

Coordinator
Sep 16, 2011 at 1:35 PM

@pointbypoint and @nielsbosma

can you guys please list me

1. your folder structure
2. the path where you call the msbuild.exe from
3. the  using task stuff from the xml file. eg.

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

and then i can help you two :)

Sep 16, 2011 at 1:57 PM

Hi, thanks for this... I am a bit of a noob at playing at this level, but did try quite a few things before seeing the other people had this...

(nb SOLFOL and PROJFOL are replaced by me for purposes of copying the errors up here...)

 

 

 

  • proj root
    • bin
      • EcmaScript.NET.modified.dll (from CodePlex, replaced the one i got from Nuget)
      • Yahoo.Yui.Compressor.dll (from CodePlex, replaced the one i got from Nuget)
    • MsBuild
      • EcmaScript.NET.modified.dll (from CodePlex, replaced the one i got from Nuget)
      • Yahoo.Yui.Compressor.dll (from CodePlex, replaced the one i got from Nuget)
      • MSBuildSettings.xml
    • Content (var css files and folders etc, presume you dont need all that

 

This is the current .csproj EOF

    </VisualStudio>
  </ProjectExtensions>
  <PropertyGroup>
    <PostBuildEvent>$(MSBuildBinPath)\msbuild.exe "$(ProjectDir)MsBuild\MSBuildSettings.xml" /p:CssOutputFile="$(TargetDir)..\Content\styles.min.css" /p:JavaScriptOutputFile="$(TargetDir)..\Scripts\javascript.min.js"</PostBuildEvent>
  </PropertyGroup>
</Project>

This is the MSBuildSettings.xml  (assembly file set to absolute path after default gave same error)

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
    <UsingTask
        TaskName="CompressorTask"
        AssemblyFile="C:\Data\Websites\SOLFOL\PROJFOL\MsBuild\Yahoo.Yui.Compressor.dll" />

    <PropertyGroup>
        <CssOutputFile Condition=" '$(CssOutputFile)'=='' ">..\Content\styles.min.css</CssOutputFile>
        <JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">..\Scripts\javascript.min.css</JavaScriptOutputFile>
    </PropertyGroup>
    
    <Target Name="MyTaskTarget">
        <!--
            ItemGroup\CssFiles or ItemGroup\JavaScriptFiles: add zero to many files you wish to include in this compression task.
                                                             Don't forget, you can use the wildcard (eg. *.css, *.js) if you feel up to it.
                                                             Finally, at least one item is required - either a css file or a js file.
                                                             
            CssFiles/JavaScriptFiles data format: Please do not touch this.
            DeleteCssFiles: [Optional] True | Yes | Yeah | Yep | True | FoSho | Fo Sho. Default is False. Anything else is False. (eg. blah = false, xxxx111 = false, etc)
            CssCompressionType: YuiStockCompression | MichaelAshsRegexEnhancements | HaveMyCakeAndEatIt or BestOfBothWorlds or Hybrid; Default is YuiStockCompression.
            ObfuscateJavaScript: [Optional] refer to DeleteCssFiles, above.
            PreserveAllSemicolons: [Optional] refer to DeleteCssFiles, above.
            DisableOptimizations: [Optional] refer to DeleteCssFiles, above.
            EncodingType: [Optional] ASCII, BigEndianUnicode, Unicode, UTF32, UTF7, UTF8, Default. Default is 'Default'.
            DeleteJavaScriptFiles: [Optional] refer to DeleteCssFiles, above.
            LineBreakPosition: [Optional] the position where a line feed is appened when the next semicolon is reached. Default is -1 (never add a line break).
                               0 (zero) means add a line break after every semicolon. (This might help with debugging troublesome files).          
            LoggingType: None | ALittleBit | HardcoreBringItOn;  Hardcore also lists javascript verbose warnings, if there are any (and there usually is :P ).
            ThreadCulture: [Optional] the culture you want the thread to run under. Default is 'en-gb'.
            IsEvalIgnored: [Optional] compress any functions that contain 'eval'. Default is False, which means a function that contains
                           'eval' will NOT be compressed. It's deemed risky to compress a function containing 'eval'. That said,
                           if the usages are deemed safe this check can be disabled by setting this value to True.
        -->
        <ItemGroup>
            <!--<JavaScriptFiles Include="..\Scripts\jquery-1.3.2.js"/>
            <JavaScriptFiles Include="..\Scripts\MicrosoftAjax.js."/>
            <JavaScriptFiles Include="..\Scripts\MicrosoftMvcAjax.js"/>-->

            <CssFiles Include="..\Content\320\css\style.css" />

        </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"
            IsEvalIgnored="false"
            />
    </Target>
</Project>



Running the above gets me an error of ....
The command "c:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "C:\Data\Websites\SOLFOL\PROJFOL\MsBuild\MSBuildSettings.xml" /p:CssOutputFile="C:\Data\Websites\SOLFOL\PROJFOL\bin\..\Content\styles.min.css" /p:JavaScriptOutputFile="C:\Data\Websites\SOLFOLDER\PROJFOLD\bin\..\Scripts\javascript.min.js"" exited with code 1.	

Let me know anything else you want me to try....


Sep 16, 2011 at 2:12 PM

if I get a little more time in a bit, I'll do a clean soln/proj and add it to a "Hello World" app and see if this persists.... Will try it as a direct download from CodePlex only....

Sep 16, 2011 at 2:40 PM

I can confirm, have just build a new application from scratch, copied config over from sample project and dlls from Codeplex download and gives me exactly the same error....

Error	1	The "CompressorTask" task could not be loaded from the assembly C:\Data\Websites\MiniTest\MiniTest\MSBuild\Yahoo.Yui.Compressor.dll. Could not load file or assembly 'file:///C:\Data\Websites\MiniTest\MiniTest\MSBuild\Yahoo.Yui.Compressor.dll' 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.	C:\Data\Websites\MiniTest\MiniTest\MSBuild\MSBuildSettings.xml	42	9	MiniTest

some more info on my system to help...

 

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel

Microsoft .NET Framework
Version 4.0.30319 SP1Rel

Installed Version: Professional

Sep 16, 2011 at 7:17 PM

I am getting the exact same error as user pointbypoint.  VS Professional Version 10.0.40219.1 using Microsoft .NET Framework Version 4.0.30319 SP1.

Coordinator
Sep 17, 2011 at 2:23 AM

awesome, folks :) i'll get onto this right now and see what the problem is.

Coordinator
Sep 17, 2011 at 4:29 AM

Hi Folks,

Ok - I got a working solution. First of all, (this is a bit embarrassing  I forgot to update my docs to make sure people use the correct dll.

Too Long; Didn't Read (TL;DR)

1. Grab the latest version of YUICompressor WITH MSBUILD TASK from NuGet. I've -replaced- v1.6.0.1 with a new v 1.6.0.1. So uninstall v1.6.0.1 and then re-install it via nuget.

2. Update your xml build file to point to the correct dll

<UsingTask
      TaskName="CompressorTask"
      AssemblyFile="<root folder for your solution>\packages\YUICompressor.NET-MsBuild-Task.1.6.0.1\lib\NET35\Yahoo.Yui.Compressor.MsBuildTask.dll" />

 

Some history/context
    Before build 1.6.0.1, the main dll had the MSBuild task inside the dll. This ment that the dll actually had a dependency on some MSBuild namespaces and references. Under some certain code conditions (they had to do with deep reflection upon the dll) the applications crashed if those MSBuild requirements were not installed on the computer. In summary, the dll sometimes cause systems to crash under very very very unique scenarios. I happen to be afflicted by that scenario :) 

So, I split the dll into two dll's.

Now, if you need to do something with MSBuild, then you need to get the NuGet package with MSBuild in it :

 

 

 

Now this new package used to contain a dependancy upon the core dll, but i just couldn't get my msbuild.xml file to work when the yuicompressor-core dll's are NOT in the same folder as the yuicompress-msbuild.dll. I thought there was a assembly reference element or something, but I could figure it out.

So the crappy solution I've done is to put the yuicompressor-core dll's AND the new yuicompressor-msbuild dll into the same nuget pacakge. *sigh*

So .. that's the first thing.

Next, change your msbuild xml file to point to the yuicompressor-msbuild file, not the core file.

It should now read like this..

 

<UsingTask
      TaskName="CompressorTask"
      AssemblyFile="<root folder for your solution>\packages\YUICompressor.NET-MsBuild-Task.1.6.0.1\lib\NET35\Yahoo.Yui.Compressor.MsBuildTask.dll"
      />

 

Of course, you need to put the correct path/location of the dll.

Tell me how this goes for you all.

Sep 17, 2011 at 9:58 AM

 

Yep, that is working now (unlike Codeplex at the moment !!!). Brilliant, thanks for the fast support on that, look forward to having a play....

Sep 20, 2011 at 6:18 PM

Purekrome, thanks, this is working for me now.   Great documentation and thanks for the quick response......

Nov 11, 2011 at 6:42 PM

It's still the same problem for v 1.6.0.2. I downloaded it with a nuget. 

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.

Jan 26, 2012 at 9:42 AM

This work for me, would it be possible to include the .MsBuild.dll in the main release? 

For those (like me) not using NuGet, simply download NuGet package explorer, search for YUI and extract the files to your regular folder. Update your .vbproj to point to .msbuild.dll instead of .dll

Coordinator
Jan 26, 2012 at 5:45 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jan 30, 2012 at 7:53 AM

Fixed in Release 1.7.0.0