title: Parse of '@import (less)' statement raises NullReferenceException in ASP .NET MVC 5 project with dotLess
body: <h2><strong>Short story</strong></h2>
  
  <p>Visual Studio 2013.3 with <a href="https://visualstudiogallery.msdn.microsoft.com/56633663-6799-41d7-9df7-0f2a504ca361" rel="nofollow">Web Essentials</a>, ASP .NET MVC 5 Project with <a href="http://www.nuget.org/packages/dotless" rel="nofollow">dotLess 1.4.1</a>. Attempt to use <code>@import (less)</code> statement inside of a simple less file, that only imports a simple css file, leads to a raise of <code>NullReferenceException</code>. <code>@import</code> without <code>(less)</code> instruction does not parsed as expected - it just being copied unparsed to the result less file. <strong>Is there a way to fix that? Or it is just a bug of dotLess?</strong></p>
  
  <hr>
  
  <h2><strong>Long story (with steps to reproduce)</strong></h2>
  
  <ol>
  <li>Create a new ASP .NET MVC 5 Project in Visual Studio 2013.3</li>
  <li>Install the latest version of <a href="http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification" rel="nofollow">dotless</a> via NuGet Package Manager</li>
  <li>Inside <code>~/Content/</code> folder create a simple <code>Site.less</code> file, that only imports the default <code>Site.css</code> files:</li>
  </ol>
  
  <p>_</p>
  
  <pre><code>@import (less) "Site.css";
  </code></pre>
  
  <ol start="4">
  <li>According to <a href="http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification" rel="nofollow">Bundling and Minification article of ASP .NET MVC 4 tutorial</a> create <code>LessTransform</code> class as follows:</li>
  </ol>
  
  <p>_</p>
  
  <pre><code>using System.Web.Optimization;
  
  public class LessTransform : IBundleTransform
  {
      public void Process(BundleContext context, BundleResponse response)
      {
          response.Content = dotless.Core.Less.Parse(response.Content);
          response.ContentType = "text/css";
      }
  }
  </code></pre>
  
  <ol start="5">
  <li>In <code>RegisterBundles</code> method inside of <code>BundleConfig</code> class in <code>BundleConfig.cs</code> file add the following lines:</li>
  </ol>
  
  <p>_</p>
  
  <pre><code>var lessBundle = new Bundle("~/Content/less").Include("~/Content/Site.less");
  lessBundle.Transforms.Add(new LessTransform());
  bundles.Add(lessBundle);
  </code></pre>
  
  <ol start="6">
  <li>In <code>_Layout.cshtml</code> file delete (or just comment out) the line:</li>
  </ol>
  
  <p>_</p>
  
  <pre><code>@Styles.Render("~/Content/css")
  </code></pre>
  
  <p>and also add the following line:</p>
  
  <pre><code>@Styles.Render("~/Content/less")
  </code></pre>
  
  <ol start="7">
  <li>Run the project</li>
  </ol>
  
  <p><strong>Result</strong>: <code>NullReferenceException</code> is thrown in <code>LessTransform</code> class on the line:</p>
  
  <pre><code>response.Content = Less.Parse(response.Content);
  </code></pre>
  
  <p><strong>Is there a way to fix that? Or it is just a bug of dotLess?</strong></p>
  
  <hr>
  
  <h2><strong>Knowledge base</strong></h2>
  
  <ol>
  <li>Changing</li>
  </ol>
  
  <p>_</p>
  
  <pre><code>@import (less) "Site.css";
  </code></pre>
  
  <p>to</p>
  
  <pre><code>@import (less) "./Site.css";
  </code></pre>
  
  <p>does not help.</p>
  
  <ol start="2">
  <li><p>Copy Always to Output Directory of <code>Site.css</code> does not help.</p></li>
  <li><p>Changing <code>@import (less) "Site.css"</code> to <code>@import "Site.css"</code> does not help since dotLess does not parse the resulting line as we expect. It just copies the line without any processing.</p></li>
  <li><p><a href="https://visualstudiogallery.msdn.microsoft.com/56633663-6799-41d7-9df7-0f2a504ca361" rel="nofollow">Web Essentials 2013 for Update 3</a> represents compiled version of the less file correctly. Nonetheless, the problem still exists.</p></li>
  </ol>