4

I wanted to know how to process a list of LESS files using the exe binaries, for example:

./dotless.Compiler.exe -m *.less

Right now I only can do individual files, but can't do wildcard.

The reason why I asked about this is that I want to create a target in MSBuild, which is to process an item collection (which is a list of files). I couldn't find a way to loop a task in side MSBuild. If anyone knows how to loop a task for each file, that would solve my problem too.

madth3
  • 7,275
  • 12
  • 50
  • 74
Grace Huang
  • 5,355
  • 5
  • 30
  • 52

1 Answers1

8

Use an ItemGroup to get a list of files like this:

<ItemGroup>
    <MyFiles Include="[path to less files]\*" />
</ItemGroup>

Call the compiler once for each file by using %(MyFiles.FullPath) syntax (also known as Task Batching)

<Target Name="CompileLess">
   <Exec Command="$(dotLessCompiler) -m %(MyFiles.FullPath)" />
</Target>
Mrchief
  • 75,126
  • 20
  • 142
  • 189
  • Do you mean the line can be converted to this command line: ./dotless.Compiler.exe -m style1.less style2.less style3.less? I don't think it will work as expected. – Grace Huang Jul 19 '11 at 17:05
  • No, it will be executed one file at a time. See my updated answer. – Mrchief Jul 19 '11 at 17:13