Question

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!

Was it helpful?

Solution 2

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top