Skip to content

Consider adding a WithoutMetadataValue msbuild item function #8205

@ViktorHofer

Description

@ViktorHofer

The following set of item functions allow to condition on or filter items based on metadata:

  • AnyHaveMetdataValue
  • HasMetadata
  • WithMetadataValue

These functions make it super simple to include items or condition based on metadata during evaluation time, without the need of batching (inside a target).

Over the last years I often wished that there would also be a WithoutMetadataValue item function so that the following pattern wouldn't require an extra target:

<Target Name="GetCompileFilteredItems">
  <ItemGroup>
    <CompileFiltered Include="@(Compile->WithMetadataValue('ExcludeFromX', ''))" />
    <CompileFiltered Include="@(Compile->WithMetadataValue('ExcludeFromX', 'false'))" />
  </ItemGroup>
</Target>

<Target Name="X"
             Inputs="@(CompileFiltered)"
             Outputs="..."
             DependsOnTargets="GetCompileFilteredItems">
  ...
</Target>

Instead, with a WithoutMetadtaValue item function, the filtering can happen just in-time without a separate target.

<Target Name="X"
             Inputs="@(Compile->WithoutMetadataValue('ExcludeFromX', 'true'))"
             Outputs="...">
  ...
</Target>

Metadata

Metadata

Assignees

Labels

Good First IssueSelf-contained issues good for first-time contributors.triaged

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions