MSBuild: Items + Batching + CreateItem + Transforms Question
- by KeithCS
I have this bit of an msbuild project that is making me wonder why it the outcome is the way it is. Not that it is causing an issue or anything of the sort, but I would like to try and better my understanding of it.
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="TestTarget1;TestTarget2" ToolsVersion="3.5">
<ItemGroup>
<PathDir Include="C:\RootDir\UniqueDir1"/>
<PathDir Include="C:\RootDir\UniqueDir2" />
</ItemGroup>
<Target Name="TestTarget1" Outputs="%(PathDir.Identity)">
<PropertyGroup>
<RootPath>%(PathDir.Identity)</RootPath>
</PropertyGroup>
<ItemGroup>
<SubDirectory Include="Common1"/>
<SubDirectory Include="Common2"/>
</ItemGroup>
<CreateItem Include="@(SubDirectory->'$(RootPath)\%(Identity)')">
<Output TaskParameter="Include" ItemName="FullPath"/>
</CreateItem>
<Message Text="@(FullPath)"/>
</Target>
<Target Name="TestTarget2">
<Message Text="@(FullPath)"/>
</Target>
</Project>
So I have two main paths that are unique, and within each I have two directories with the same names in each of the unique paths. In target1, I am batching against the identity of the items in PathDir, and then performing a transform on item SubDirectory, which contains the common folder names found in the unique directories, to create a new item containing the full paths. So anyways, after that, the output for the targets is as follows:
Target 1:
C:\RootDir\UniqueDir1\Common1;C:\RootDir\UniqueDir1\Common2
C:\RootDir\UniqueDir2\Common1;C:\RootDir\UniqueDir2\Common2
Target 2:
C:\RootDir\UniqueDir1\Common1;C:\RootDir\UniqueDir1\Common2;C:\RootDir\UniqueDir2\Common1;C:\RootDir\UniqueDir2\Common2
So my question I guess is ... why does target1 only display the directories containing the directory it is batching against? I know it probably has to do with batching, but thats all I know.