Skip to content

Add built-in First and Last item functions #4859

Open
@kzu

Description

@kzu

Sometimes it's useful to take just the first item on a list, or the last. This is currently very cumbersome, to the point that it's "easier" just write an inline task to do so.

A new First() and Last() item function would simplify things a lot.

Usage example:

   <Target Name="Split">
        <ItemGroup>
            <BranchParts Include="release;v1.3.1" />
        </ItemGroup>

        <Message Text="@(BranchParts -> Last())" Importance="high" />
        <Message Text="@(BranchParts -> First())" Importance="high" />
    </Target>

Renders:

v1.3.0
release

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: LanguageIssues impacting the MSBuild programming language.gathering-feedbackThe issue requires feedback in order to be planned, please comment if the feature is useful for youtriaged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions