Skip to content

Instantly share code, notes, and snippets.

@javafun
Forked from colin-han/less.targets
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javafun/b04fc458aa97717db77d to your computer and use it in GitHub Desktop.
Save javafun/b04fc458aa97717db77d to your computer and use it in GitHub Desktop.
<!--
Usage:
1. Download this file into your project folder, named it as "Less.targets"
2. Use notepad to open your project file (e.g. Example.csproj), and put following code to above of end element 'Project'.
<Import Project="Less.targets" />
3. Change element type of *.less file in your project file to "LessCompile".
You need to do that manual first time. After that, you can change the file's "build action" to 'LessCompile' through PropertyGrid.
4. Close notepad and reload your project in VisualStudio. Then press F6 to build your project.
You will found the css file will be generated by build process automatically.
-->
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CompileDependsOn>
CompileLess;
$(CompileDependsOn);
</CompileDependsOn>
</PropertyGroup>
<PropertyGroup>
<LessBuildConfigurations>--no-color</LessBuildConfigurations>
</PropertyGroup>
<ItemGroup>
<LessCompileArgs Include="@(LessCompile -> '&quot;%(fullpath)&quot; &quot;%(rootdir)%(directory)%(filename).css&quot;')" />
</ItemGroup>
<Target Name="CompileLess">
<Message Text="Compiling Less files" />
<Message Text="Executing lessc $(LessBuildConfigurations) %(LessCompileArgs.Identity)" />
<Exec Command="&quot;$(APPDATA)\npm\lessc.cmd&quot; $(LessBuildConfigurations) %(LessCompileArgs.Identity)" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment