0

How can we find a specific file type under a path? I have checked MSBuild Task Reference but couldn't figure out.

Looking for something as:

<FindUnderPath Path="$(OutDir)"  Files="*.txt">
    <Output TaskParameter="InPath" ItemName="AllTxtFiles"/>
</FindUnderPath>

But it fails sayings "MSB3541: Files has invalid value "*.txt""

P.S. I am a rookie at msbuild tasks!

Community
  • 1
  • 1
dushyantp
  • 4,398
  • 7
  • 37
  • 59

2 Answers2

4

If you just need list of all txt files in certain folder you can get it as simple as

<ItemGroup>
    <AllTxtFiles Include="$(PathToFolder)\**\*.txt" />
</ItemGroup>

Double stars (**) means that folder should be searched recursively for file pattern

Alexey Shcherbak
  • 3,394
  • 2
  • 27
  • 44
1

You could use an ItemGroup to specify such files and reference the ItemGroup in the Files parameter. Something like:

<ItemGroup>
    <MyFiles Include="*.txt" />
</ItemGroup>
<FindUnderPath Path="$(OutDir)" Files="@(MyFiles)">
    <Output TaskParameter="InPath" ItemName="AllTxtFiles" />         
</FindUnderPath>

Source: http://msdn.microsoft.com/en-us/library/vstudio/ms164293(v=vs.120).aspx

rla4
  • 1,228
  • 13
  • 25