1

Closed

CSS Minify with # for first character

description

i have an issue with Ajax Minifyer 4.21 and the previous version.
I have in my aspx page, this entry :
<div id="header" ...>
in my css file, i have this :

header{ color:White;...}

 
when i want to minify the file with this value in my csproj's file :
<UsingTask TaskName="JSBuild.CSSBuildTask" AssemblyFile="$(MSBuildProjectDirectory)....\SharedBinaries\JSBuild\JSBuild.dll" />
<CSSBuildTask SourceFiles="@(PreCSS)" SourceDirectory="$(MSBuildProjectDirectory)" DestinationDirectory="ScriptOutput" />
 
I have this error :
unknown directive HEADER, on the line which start with <CSSBuildTask .
 
It works for my js file.
 
If i change #header to .header, the minifyer works.
Closed Jul 3, 2012 at 5:27 PM by ronlo
Shouldn't use "Compile" property for CSS files in your project.

comments

ronlo wrote Jun 7, 2011 at 6:37 PM

I created a file named devbfd.css that contained one line: #header{color:White;}. When I run it through AjaxMin version 4.21 on the command-line, it works just fine with no errors. Can you attach a CSS file that repros the error?

ronlo wrote Jun 7, 2011 at 7:00 PM

Your <UsingTask> element is calling JSBuild.dll. Shouldn't you be calling AjaxMinTask.dll?

ronlo wrote Jun 7, 2011 at 7:55 PM

I was able to repro if I set the CSS file's Build Action property to "Compile" -- don't do that. Apparently that causes MSBuild to run your source through the C# compiler, and of course it's not C# code. Make sure the build action on your CSS file is Embedded Resource. I was using this in my proj file:

<UsingTask TaskName="AjaxMin" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmintask.dll" />
<Target Name="AfterBuild">
<ItemGroup>
  <CSS Include="**\*.css" Exclude="**\*.min.css" />
</ItemGroup>
<AjaxMin CssSourceFiles="@(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" />
</Target>

(obviously, you'd want to use the proper path to AjaxMinTask.dll on your machine)

There's a good article at http://www.codeproject.com/Articles/81317/Automatically-compress-embedded-JavaScript-resourc.aspx that explains some better project build markup (I am no expert at MSBuild).