Given item types A and B, there should be an easy way in MSBuild to merge B into A.
Possible ways to do merging:
Probably the most useful merging is intersection item merging with additive metadata. Possible syntax implementations for only this type of merging:
<Foo Update="@(Bar)"> // applies all the metadata from Bar into Foo
<Foo Update="@(Bar)" KeepMetadata="Tar"> // applies only metadata named "Tar" from Bar into Foo
<Foo Update="@(Bar)" RemoveMetadata="Tar"> // applies all metadata except "Tar" from Bar into Foo
The drawback is that MSBuild currently treats <Foo Update="@(Bar)"/> as a noop (i.e. for all items in Foo that match in Bar, do nothing), so we'll break the existing noop behaviour. Since it's a pretty benign behaviour, it probably doesn't happen too often.
Merge operation<Foo Merge="@(Bar)"> // applies all the metadata from Bar into Foo
<Foo Merge="@(Bar)" KeepMetadata="Tar"> // applies only metadata named "Tar" from Bar into Foo
<Foo Merge="@(Bar)" RemoveMetadata="Tar"> // applies all metadata except "Tar" from Bar into Foo
The advantages of Merge:
<Foo Merge="@(Bar)" MetadataMergeStrategy="overwrite" ItemMergeStrategy="Union">)Are there patterns for how any of these can be implemented today within targets, esp. _Intersection_ with merging of metadata?
/cc @nguerrera, @rainersigwald
I would implement a task @vatsan-madhavan. It's often possible to do it in pure MSBuild but IME the output is incomprehensible even to the author as of about half an hour after writing it.
Most helpful comment
I would implement a task @vatsan-madhavan. It's often possible to do it in pure MSBuild but IME the output is incomprehensible even to the author as of about half an hour after writing it.