Skip to content

Instantly share code, notes, and snippets.

@shadow-cs
Last active Jan 10, 2021
Embed
What would you like to do?
MSBuild: Selecting first and last items in an ItemGroup
<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