How does the ""RecursiveDir"" attribute work?
The ""RecursiveDir"" item attribute is set automatically by the ""MSBuild"" engine for any item that was expanded from a recursive wildcard syntax "
*" in the project file. The value of ""RecursiveDir"" will be equivalent to the path to the file, beginning at the location of the "*". For example, suppose you had the following directory structure:
c:\
[MSBuild\]
Team\
Brett.txt
Chris\
Rajeev.txt
Sumedh.txt
Jomo.txt
Lukasz.txt
Rob\
Dan.txt
Victor.txt
Jeff.txt
Chad\
Alex.txt
Kieran.txt
Editor\
subdirE\
whatever.txt
subdirF\
whichever.txt
IDE\
subdirG\
however.txt
and you wrote the following project file :
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
[<ItemGroup>]
<Areas Include="c:\MSBuild\**\*.txt" />
[</ItemGroup>]
<Target Name="Build">
<Message Text="FullPath RecursiveDir"/>
<Message Text="======== ============"/>
<Message Text="@(Areas->'%(FullPath) [%(RecursiveDir)',] '&#13;&#10;')"/>
</Target>
</Project>
then you would end up with this output:
Target "Build" in project "testrecursion.proj"
[FullPath] [RecursiveDir]
======== ============
[c:\MSBuild\Team\Brett.txt] Team\
[c:\MSBuild\Team\Chad\Alex.txt] Team\Chad\
[c:\MSBuild\Team\Chad\Kieran.txt] Team\Chad\
[c:\MSBuild\Team\Chris\Jomo.txt] Team\Chris\
[c:\MSBuild\Team\Chris\Lukasz.txt] Team\Chris\
[c:\MSBuild\Team\Chris\Rajeev.txt] Team\Chris\
[c:\MSBuild\Team\Chris\Sumedh.txt] Team\Chris\
[c:\MSBuild\Team\Rob\Dan.txt] Team\Rob\
[c:\MSBuild\Team\Rob\Jeff.txt] Team\Rob\
[c:\MSBuild\Team\Rob\Victor.txt] Team\Rob\