I wonder if there is a way to precompile *.less
files(http://www.dotlesscss.org/) with visual studio.
The site gives me a dotless.compiler.exe
Here's the solution I came up with, using MSBuild. It's incremental, so it should only happen when the Less changes. It also correctly handles @import
.
First, add dotless to your project with NuGet. You don't need any of the magic it adds to your web.config
, so you can revert that - you're just using it to get the compiler executable.
Next, add your "root" Less files to your .csproj
, like so:
Finally, add this snippet at the bottom of your .csproj
: