Error finding LESS file when compiling

Jul 6, 2012 at 2:28 PM

I configured combres to use Twitter Bootstrap less files and its working when I'm on debug mode but when the option is set to false it throws this error:


System.IO.FileNotFoundException: You are importing a file ending in .less that cannot be found.


I'm using MVC4, VS2010, Combres installed from nuget


Thanks for any help


Jul 9, 2012 at 6:45 PM

Hi, thanks for reporting. Can you post the sample project containing just the error for easy reproducing & troubleshooting?

Jul 9, 2012 at 7:49 PM

Sure, download the project from here

On combres.xml change defaultDebugEnabled from true to false and it will fail when loading that resource set.


Jul 10, 2012 at 10:53 PM

Hi, thanks for posting the code.  There's a closely related issue reported here.  For Combres to work in these scenarios, you have to remove all the @import in the less file and reference those files directly in combres.xml; then use DotLessCssCombineFilter to process those less files. Your combres.xml should look something like this:

<?xml version="1.0" encoding="utf-8"?>

  This file contains basic settings needed for most web apps.
  For full Combres settings (with explanation), refer to the sample definition file: combres_full_with_annotation.xml
  Also, refer to Combres' documentation:	
<combres xmlns='urn:combres'>
    <filter type="Combres.Filters.FixUrlsInCssFilter, Combres" />
    <filter type="Combres.Filters.HandleCssVariablesFilter, Combres" />
    <filter type="Combres.Filters.DotLessCssFilter, Combres" />
    <filter type="Combres.Filters.DotLessCssCombineFilter, Combres" 
    <minifier name="yui" type="Combres.Minifiers.YuiCssMinifier, Combres">
      <param name="CssCompressionType" type="string" value="StockYuiCompressor" />
      <param name="RemoveComments" type="bool" value="true" />
      <param name="ColumnWidth" type="int" value="-1" />
    <minifier name="yui" type="Combres.Minifiers.YuiJSMinifier, Combres">
      <param name="IsVerboseLogging" type="bool" value="false" />
      <param name="IsObfuscateJavascript" type="bool" value="true" />
      <param name="PreserveAllSemicolons" type="bool" value="false" />
      <param name="DisableOptimizations" type="bool" value="false" />
      <param name="LineBreakPosition" type="int" value="-1" />
  <resourceSets url="~/combres" 
    <resourceSet name="bootstrap-theme-css" type="css">
      <resource path="~/Content/themes/bootstrap/less/reset.less" />
      <resource path="~/Content/themes/bootstrap/less/variables.less" />
      <resource path="~/Content/themes/bootstrap/less/mixins.less" />>
      <!-- more resources here -->

Jul 11, 2012 at 3:47 PM

Hi buunguyen, thanks for the help. I removed the imports, added al less files and added the filter and it didn’t work, but it didn’t throw any errors this time. If I’m in debug mode the server responds with a blank file for each less file. Where you able to make it work with the project I sent?


Jul 31, 2012 at 5:10 PM

Here is what I believe to be the correct implementation of the dotless filter that handles imports correctly. Please let me know if you would like me to fork the fix for you guys.

Aug 11, 2012 at 11:39 PM

@malave: can you send the sample project again?

@theonlylawislove: nice, does it work with parent folder, e.g. ../another.less?

Aug 14, 2012 at 4:39 PM

@buunguyen the link still, I haven’t tried @theonlylawislove yet but most likely I will try it sometime today

Aug 16, 2012 at 11:31 PM

#buunguyen: Yes, the following work all work.

  • @import "variables.less"
  • @import "~/variables.less"
  • @import "../../variables.less"
  • @import "folder/variables.less"
Aug 17, 2012 at 3:46 AM

@theonlylawislove: looks good. Couple of issues:

  • The previous implementation explicitly prevents DotLess to minify and cache to avoid double-minification and -caching; can this do the same?
  • Can you make it work with ICombinedContentFilter as well?
Aug 17, 2012 at 1:47 PM

@buunguyen: I wasn't aware of that when looking into the out-of-the-box implementation. I can check though. It can work with the combined filter, but since the imports work, I personally wouldn't recommend using it. It only minifies .less files, and it it is combined, it will use the entire contents of all the css files in the resource set. Is this a required feature? I think people only used the combined approach because imports didn't work.

Aug 18, 2012 at 8:15 PM

@theonlylawislove: that makes sense; I guess it just gives people flexibility, they can either do all imports within .less files or add individual files in the config and have DotLess runs on the combined string of all files. That should yield similar effect as long as the order is kept right.

The latter has one benefit since now Combres knows about the files being used to generate a response, its change tracking mechanism can monitor changes to the file to generate a new content hash (which cause the url to change => effectively force an auto refresh from browser).  Current change tracking doesn't coordinate with filter/minifier, so Combres wouldn't know about internal imported resources via @import.  Not every one needs this feature (they use manual versioning, or are just happy with the cache settings...) but I, for one, am using auto versioning a lot.

In addition, I don't want to break people's existing code :).

In sort, I still think it's nice to have this combined filter implemented. So if you can help check this out, it's much appreciated.