Search code examples
visual-studiomsbuildmsbuild-task

Msbuild task to find specific filetype


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!


Solution

  • 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