Filter MSBuild items
- Hi Guys,
Problem:
I'm trying to filter a item list (GroupA), with item list (GroupB) to generate GroupC. So far I have tried this using batching and Transforms with no luck.
Background:
GroupA is a list been generated from a custom Msbuild task. Its metadata structure cannot be changed. The idea here is to search GroupA for list of filenames contained within GroupB.
<
GroupA Include="ann.exe"/>
<GroupA Include="barry.exe"/>
<GroupA Include="claire.exe"/>
<GroupA Include="dermot.exe"/><
GroupB Include="ann.exe"/>
<GroupB Include="barry.exe"/>
Possible solution:
<
CreateItem Include="@(GroupA)" Condition="'%(GroupA.filename)' == 'ann' or '%(GroupA.filename)' == 'barry'" >
<Output TaskParameter="Include" ItemName="GroupC"/>
</CreateItem>Any help on this would be appreciated.
Thanks
John
Ответы
- I think the following will work for you
<FTDMsBuild TaskAction="GetCommonItems" InputItems1="@(GroupA)" InputItems2="@(GroupB)">
<Output TaskParameter="OutputItems" ItemName="GroupC"/>
</FTDMsBuild>
The task is in the FreeToDev MSBuild Tasks Suite, available here: http://www.codeplex.com/freetodevtasks
That task will do a bunch of other things for you too...GetCommonItems (Required: InputItems1, InputItems2 Output: OutputItems, ItemCount)
GetDistinctItems (Required: InputItems1, InputItems2 Output: OutputItems, ItemCount)
GetItem (Required: InputItems1, PositionOutput: OutputItems)
GetLastItem (Required: InputItems1Output: OutputItems)
GetItemCount (Required: InputItems1 Output: ItemCount)
GetCurrentDirectory (Output: CurrentDirectory)
RemoveDuplicateFiles (Required: InputItems1 Output: OutputItems, ItemCount)
Sort (Required: InputItems1Output: OutputItems)
StringToItemCol (Required: ItemString, Separator Output: OutputItems, ItemCount)
- Помечено в качестве ответаFeng ChenМодератор26 сентября 2008 г. 9:22
I tried several different ways to make this work. I ended up having to do to two excludes to perform an inner join in MSBuild without outside tasks.
<CreateItem Include="@(GroupA)" Exclude="@(GroupB)" >
<Output TaskParameter="Include" ItemName="GroupC"/>
</CreateItem>
<CreateItem Include="@(GroupA)" Exclude="@(GroupC)" >
<Output TaskParameter="Include" ItemName="GroupD"/>
</CreateItem>
<Message Text="@(GroupD)"/>
KodefuGuru.com - Life Student of the Kodefu Arts- Помечено в качестве ответаFeng ChenМодератор26 сентября 2008 г. 9:22
Все ответы
- I think the following will work for you
<FTDMsBuild TaskAction="GetCommonItems" InputItems1="@(GroupA)" InputItems2="@(GroupB)">
<Output TaskParameter="OutputItems" ItemName="GroupC"/>
</FTDMsBuild>
The task is in the FreeToDev MSBuild Tasks Suite, available here: http://www.codeplex.com/freetodevtasks
That task will do a bunch of other things for you too...GetCommonItems (Required: InputItems1, InputItems2 Output: OutputItems, ItemCount)
GetDistinctItems (Required: InputItems1, InputItems2 Output: OutputItems, ItemCount)
GetItem (Required: InputItems1, PositionOutput: OutputItems)
GetLastItem (Required: InputItems1Output: OutputItems)
GetItemCount (Required: InputItems1 Output: ItemCount)
GetCurrentDirectory (Output: CurrentDirectory)
RemoveDuplicateFiles (Required: InputItems1 Output: OutputItems, ItemCount)
Sort (Required: InputItems1Output: OutputItems)
StringToItemCol (Required: ItemString, Separator Output: OutputItems, ItemCount)
- Помечено в качестве ответаFeng ChenМодератор26 сентября 2008 г. 9:22
I tried several different ways to make this work. I ended up having to do to two excludes to perform an inner join in MSBuild without outside tasks.
<CreateItem Include="@(GroupA)" Exclude="@(GroupB)" >
<Output TaskParameter="Include" ItemName="GroupC"/>
</CreateItem>
<CreateItem Include="@(GroupA)" Exclude="@(GroupC)" >
<Output TaskParameter="Include" ItemName="GroupD"/>
</CreateItem>
<Message Text="@(GroupD)"/>
KodefuGuru.com - Life Student of the Kodefu Arts- Помечено в качестве ответаFeng ChenМодератор26 сентября 2008 г. 9:22
- I posted a blog article explaining set operations with item collections in more detail.
http://www.kodefuguru.com/post/2008/09/Set-Operations-in-MSBuild.aspx
KodefuGuru.com - Life Student of the Kodefu Arts

