Blog Entry For 5/1/2015
WebEssentials, LESS and a 404
I was recently playing around with a new project for work, just a simple MVC website to host some useful resources for my fellow developers. I was using the WebEssentials 2012 plugin for Visual Studio to handle the preprocessing of my LESS files as well as handling automatic minification of my JavaScript files, nothing strange there. With WebEssentials, Visual Studio has great LESS support with some rather nice Intellisense extras to keep your styles in check.
Everything was fine, except for the first time I happened to save a LESS file. Normally my settings are to generate the minified CSS files on save, but this time I got the message "LESS: 'C:\BLAHBLAH.LESS' wasn't found (404)". This was strange for a few reasons, one of which is that the BLAHBLAH.LESS file was in a subdirectory of a folder I use for all my SubVersioned projects. It most certainly wasn't in my root folder! not to mention, it did exist, as I was looking at it when I hit save. Time for a little detective work...
At first, I thought it was a well known issue with relative import URLs - see here. However, no such links existed in the project. After much digging, I finally dropped down to manually executing the compilation command from the command line to see if WebEssentials or the LESS compiler itself was the issue.
Running the compiler directly, the same issue occurred. Right...something must be strange about the file path. I removed all spaces from the path and still the issue remained. Finally, an answer stood out.
I have a habit of naming folders with '#' as a prefix if I use them a lot and want them to always be at the top of a folder tree when in alphabetical sort order. This was the issue. It's presence in the URI clearly caused the LESS compiler to throw a little tetchy wobbler. I removed the hash symbol and everything was fine.
WebEssentials is indeed an essential tool for me, hopefully you already use it or you want to see what it can do for you - vswebessentials.com
1/5/2015 Tags: webessentials less 404