Last active
November 18, 2021 09:43
-
-
Save shadow-cs/cb5499b010bdacd1f778be29daf7f04c to your computer and use it in GitHub Desktop.
MSBuild: Selecting first and last items in an ItemGroup
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
<Project DefaultTargets="Default"> | |
<ItemGroup> | |
<Items Include="One;Two;Three;Four;Five" /> | |
</ItemGroup> | |
<Target Name="Default"> | |
<ItemGroup> | |
<Reversed Include="@(Items->Reverse())" /> | |
</ItemGroup> | |
<PropertyGroup> | |
<First>%(Reversed.Identity)</First> | |
<Last>%(Items.Identity)</Last> | |
</PropertyGroup> | |
<Warning Text="First: $(First)" /> | |
<Warning Text="Last: $(Last)" /> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment