3

I know how you can use dotless to have LESS file(s) compiled into CSS when bundling in an MVC app. What I want to be able do, though, is control the LESS-to-CSS conversion in a C#/.NET application outside of the scope of bundling. Is there a way to either define a destination location in the file system or retrieve a stream of the CSS file in code using Cassette.less?

6
  • You need to include the less.js library. lesscss.org/#download-options Commented Aug 27, 2014 at 20:10
  • I'm currently using Cassette.Less, available as a NuGet package. But unfortunately, questions asking for a tool are not in the scope of StackOverflow, and I'll have to vote to close. Commented Aug 27, 2014 at 20:11
  • Nice try! :P ... Cassette use dotLess internally, only makes easier to configure, bundle and cache your scripts. You can check how to configure cassette here or use only dotless, their have a 5-step configuration on their main page Commented Aug 27, 2014 at 20:29
  • @Andre: This will allow me to compile LESS to CSS in code? I specifically am trying to convert LESS files to CSS in a C# console app where bundling doesn't exist. Commented Aug 27, 2014 at 20:33
  • I wonder if the easiest thing is to just download lessc and invoke it via System.Diagnostics.Process.Start()... Commented Aug 27, 2014 at 20:40

2 Answers 2

2

You can reference the dotless.Core.dll in your C# console app and than call Less.Parse();. The Less.Parse(); only accepts code. If you will have to compile a file (with imports) you can use the dotless.Compiler command as suggested by @im1dermike.

See also: http://tedgustaf.com/blog/2010/11/setup-dotless-in-aspnet-project/

Sign up to request clarification or add additional context in comments.

Comments

1

The simplest way is to use Web Essentials to compile LESS into CSS for you. You can then use the generated file for bundling.

If you wanted even more control over the process you could always create a grunt/gulp task to compile the LESS.

Compile LESS files with Grunt

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.