Created
March 20, 2010 13:10
-
-
Save esfand/338659 to your computer and use it in GitHub Desktop.
MSBuild Batching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<ItemGroup> | |
<GroupA Include="file1.txt"/> | |
<GroupA Include="file2.txt"/> | |
<GroupA Include="file3.txt"/> | |
<GroupA Include="file4.txt"/> | |
</ItemGroup> | |
<ItemGroup> | |
<GroupB Include="file1.txt"/> | |
<GroupB Include="file3.txt"/> | |
<GroupB Include="file5.txt"/> | |
</ItemGroup> | |
<Target Name="Build"> | |
<CreateItem Include="@(GroupA)" Condition="'%(Identity)' != _ and '@(GroupA)' != _ and '@(GroupB)' != ''"> | |
<Output TaskParameter="Include" ItemName="GroupC"/> | |
</CreateItem> | |
<Message Text="@(GroupC)"/> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<ItemGroup> | |
<fruit Include="apple"/> | |
<fruit Include="rhubarb"/> | |
<fruit Include="apricot"/> | |
<form Include="cake"/> | |
<form Include="pie"/> | |
<form Include="sorbet"/> | |
<form Include="mousse"/> | |
</ItemGroup> | |
<Target Name="Baking" Inputs="@(fruit)" Outputs="%(identity)"> | |
<Message Text="@(fruit) %(form.identity)"/> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<ItemGroup> | |
<ExampColl Include="Item1"> | |
<Number>1</Number> | |
</ExampColl> | |
<ExampColl Include="Item2"> | |
<Number>2</Number> | |
</ExampColl> | |
<ExampColl Include="Item3"> | |
<Number>3</Number> | |
</ExampColl> | |
<ExampColl Include="Item4"> | |
<Number>1</Number> | |
</ExampColl> | |
<ExampColl Include="Item5"> | |
<Number>2</Number> | |
</ExampColl> | |
<ExampColl Include="Item6"> | |
<Number>3</Number> | |
</ExampColl> | |
</ItemGroup> | |
<Target Name="ShowMessage"> | |
<Message Text = "Number: %(ExampColl.Number) -- Items in ExampColl: @(ExampColl)"/> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<ItemGroup> | |
<ExampColl Include="Item1"> | |
<Number>1</Number> | |
</ExampColl> | |
<ExampColl Include="Item2"> | |
<Number>2</Number> | |
</ExampColl> | |
<ExampColl Include="Item3"> | |
<Number>3</Number> | |
</ExampColl> | |
<ExampColl2 Include="Item4"> | |
<Number>1</Number> | |
</ExampColl2> | |
<ExampColl2 Include="Item5"> | |
<Number>2</Number> | |
</ExampColl2> | |
<ExampColl2 Include="Item6"> | |
<Number>3</Number> | |
</ExampColl2> | |
</ItemGroup> | |
<Target Name="ShowMessage"> | |
<Message | |
Text = "Number: %(Number) -- Items in ExampColl: @(ExampColl) ExampColl2: @(ExampColl2)"/> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<ItemGroup> | |
<ExampColl Include="Item1"/> | |
<ExampColl Include="Item2"/> | |
<ExampColl Include="Item3"/> | |
<ExampColl Include="Item4"/> | |
<ExampColl Include="Item5"/> | |
<ExampColl Include="Item6"/> | |
</ItemGroup> | |
<Target Name="ShowMessage"> | |
<Message Text = "Identity: "%(Identity)" -- Items in ExampColl: @(ExampColl)"/> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<ItemGroup> | |
<ExampColl Include="Item1"> | |
<Number>1</Number> | |
</ExampColl> | |
<ExampColl Include="Item2"> | |
<Number>2</Number> | |
</ExampColl> | |
<ExampColl Include="Item3"> | |
<Number>3</Number> | |
</ExampColl> | |
<ExampColl Include="Item4"> | |
<Number>1</Number> | |
</ExampColl> | |
<ExampColl Include="Item5"> | |
<Number>2</Number> | |
</ExampColl> | |
<ExampColl Include="Item6"> | |
<Number>3</Number> | |
</ExampColl> | |
</ItemGroup> | |
<Target Name="Exec"> | |
<Message | |
Text = "Items in ExampColl: @(ExampColl)" | |
Condition="'%(Number)'=='2'"/> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project DefaultTargets="PrintFooAndBar" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" > | |
<ItemGroup> | |
<Foo Include="foo1"> | |
<FooMetadata>1</FooMetadata> | |
</Foo> | |
<Foo Include="foo2"> | |
<FooMetadata>2</FooMetadata> | |
</Foo> | |
</ItemGroup> | |
<ItemGroup> | |
<Bar Include="bar1"> | |
<BarMetadata>a</BarMetadata> | |
</Bar> | |
<Bar Include="bar2"> | |
<BarMetadata>b</BarMetadata> | |
</Bar> | |
</ItemGroup> | |
<Target Name="PrintFooAndBar"> | |
<!-- | |
foreach (Item foo in ItemGroup) | |
{ | |
<Message Importance="high" Text="FooMetadata=" + foo.FooMetadata + ", BarMetadata=" /> | |
} | |
foreach (Item bar in ItemGroup) | |
{ | |
<Message Importance="high" Text="FooMetadata=, BarMetadata=" + bar.BarMetadata /> | |
} | |
--> | |
<Message Importance="high" Text="FooMetadata=%(Foo.FooMetadata), BarMetadata=%(Bar.BarMetadata)" /> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project DefaultTargets="PrintFoo" | |
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" > | |
<ItemGroup> | |
<Foo Include="foo1"> | |
<FooMetadata>1</FooMetadata> | |
</Foo> | |
<Foo Include="foo2"> | |
<FooMetadata>2</FooMetadata> | |
</Foo> | |
</ItemGroup> | |
<Target Name="PrintFoo"> | |
<!-- | |
foreach (Item foo in ItemGroup) | |
{ | |
<Message Importance="high" Text="FooMetadata=" + foo.FooMetadata /> | |
} | |
--> | |
<Message Importance="high" Text="FooMetadata=%(Foo.FooMetadata)" /> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project DefaultTargets="PrintFooAndBar" | |
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" > | |
<ItemGroup> | |
<Foo Include="foo1"> | |
<FooMetadata>1</FooMetadata> | |
</Foo> | |
<Foo Include="foo2"> | |
<FooMetadata>2</FooMetadata> | |
</Foo> | |
</ItemGroup> | |
<ItemGroup> | |
<Bar Include="bar1"> | |
<BarMetadata>a</BarMetadata> | |
</Bar> | |
<Bar Include="bar2"> | |
<BarMetadata>b</BarMetadata> | |
</Bar> | |
</ItemGroup> | |
<Target Name="PrintFooAndBar"> | |
<!-- Create a new list of Items that contain the cross product of Bar and Foo --> | |
<CreateItem Include="@(Bar)" | |
AdditionalMetadata="FooMetadata=%(Foo.FooMetadata)"> | |
<Output ItemName="InternalBar" TaskParameter="Include"/> | |
</CreateItem> | |
<!-- Print the contents of the new list --> | |
<Message Importance="high" | |
Text="FooMetadata=%(InternalBar.FooMetadata), BarMetadata=%(InternalBar.BarMetadata)" /> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<!-- MSBuild Batching --> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<ItemGroup> | |
<fruit Include="apple"> | |
<consistency>firm</consistency> | |
</fruit> | |
<fruit Include="orange"> | |
<consistency>pulpy</consistency> | |
</fruit> | |
<fruit Include="banana"> | |
<consistency>softish</consistency> | |
</fruit> | |
<fruit Include="pear"> | |
<consistency>unsound</consistency> | |
</fruit> | |
<fruit Include="apricot"> | |
<consistency>unsound</consistency> | |
</fruit> | |
</ItemGroup> | |
<Target Name="Compost"> | |
<Message Text="%(fruit.identity)" Condition="%(consistency) == 'pulpy' or %(consistency) == 'unsound' "/> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment