views:

441

answers:

5

I wonder if there is a way to precompile *.less files(http://www.dotlesscss.com/) with visual studio. The site gives me a dotless.compiler.exe but I am not sure how to hook this up to visual studio. I am looking for a solution for both Webforms and Mvc.

Friendly Greetings,

Pickels

+1  A: 

Phil Haack to the rescue: http://haacked.com/archive/2009/12/02/t4-template-for-less-css.aspx

Whenever you want to have something generated in your solution at compile time, T4 is usually the way to go...

Rob Fonseca-Ensor
Also the T4 templates are now part of the dotless project and get generated by the buildserver on every commit (Phil's templates are now out of date). You can get the latest t4css from the dotless buildserver by clicking the download button on our website http://www.dotlesscss.com
Tigraine
+1  A: 

Depending on your build environment, you can kick off dotless.Compiler.exe as a build task.

For example, using a Pre-Build task in Visual Studio:

$(SolutionDir)Tools\dotLess\dotless.compiler.exe -m $(ProjectDir)content\css\site.less $(ProjectDir)content\css\site.css

The macros ($(SolutionDir), etc) allow a bit of flexibility to project and file locations. Rather than using the standard .less files, simply reference the new .css files in your markup.

David Longnecker
+1  A: 

There is also another way to precompile during development.

The dotless project features a commandline compiler (dotless.Compiler.exe) that can compile and minify the CSS.

You can also use the compiler.exe with the --watch parameter where it will keep running and scan your input file for changes, regenerating whenever you make changes to the file. Thus making you independent from Visual Studio.

Tigraine
Thanks this is a really good tip.
Pickels
That's why we wrote that feature.. Got too many questions from php developers who'd love to use dotless but didn't care about all the .NET specific stuff. And dotless is after all only one exe and one dll, as opposed to ruby.
Tigraine
A: 

In my search for working with DotLess I also found this library:

http://www.codethinked.com/post/2010/03/17/Bundler-Now-Supports-Css-And-less.aspx

Adding it to my own question because it might help others.

Pickels
+4  A: 

Found this amazing tool called Zippy Chirp: http://www.weirdlover.com/2010/05/22/visual-studio-add-in-for-dotless-js-and-css-files/

Chris F