.netmsbuildcompressionyui-compressor

.NET YUI Compressor: How to include all but one css/js files from the same directory?


I hooked up YUI Compressor to my MVC 3 project. I got one folder with css files and another one with js files. When building, I want to include all of the files from css directory, except for one. Same goes for js. How can I accomplish that?

Here is the XML:

<Target Name="AfterBuild">
  <CallTarget Targets="Compress" Condition=" '$(Configuration)' == 'Release' " />
</Target>
<Target Name="Compress">
  <ItemGroup>
    <!-- Single files, listed in order of dependency.  Use * for wildcards -->
    <CssFiles Include="$(ProjectDir)\Content\*.css" Exclude="$(ProjectDir)Content\All.css" />
    <JavaScriptFiles Include="$(ProjectDir)\Scripts\*.js" Exclude="$(ProjectDir)Scripts\All.js" />
  </ItemGroup>
  <MakeDir Directories="$(ProjectDir)..\JsCssRelease" />
  <CompressorTask 
     CssFiles="@(CssFiles)" 
     DeleteCssFiles="false" 
     CssOutputFile="$(ProjectDir)..\JsCssRelease\All.css"
     CssCompressionType="YuiStockCompression" 
     JavaScriptFiles="@(JavaScriptFiles)" 
     ObfuscateJavaScript="True" 
     PreserveAllSemicolons="True" 
     DisableOptimizations="False" 
     EncodingType="Default" 
     DeleteJavaScriptFiles="false" 
     LineBreakPosition="-1" 
     JavaScriptOutputFile="$(ProjectDir)..\JsCssRelease\All.js" 
     LoggingType="ALittleBit" 
     ThreadCulture="en-us" 
     IsEvalIgnored="false" />
</Target>

I can't seem to find any more info then there is at http://yuicompressor.codeplex.com/.

What currently happens is that it includes all files and doesn't exclude the ones specified.


Solution

  • driushkin's comment was on the right way. You have an extra slash after $(ProjectDir) in the Include attribute but not on the Exclude one, leading to different file names, even if \\ instead of \ still works to access the files.