This should be simple, but I can't find how to do this (or maybe it's not possible).
In MSBuild I have an ItemGroup that is a list of files. I want to execute a task only if a particular file is in that ItemGroup
Something like:
<Copy Condition="@(Files) <contains> C:\MyFile.txt" .... />
Any way to do this? Preferably without writing a custom task.
Edit: The list of files is only to do with the condition. Otherwise it has no relation to the task.
In addition to the generic Item element, ItemGroup allows child elements that represent types of items, such as Reference , ProjectReference , Compile , and others as listed at Common MSBuild project items.
An item group is a collection of products which share similar attributes like color, production, features, or usage. Item groups can also be formed based on the markets in which they're sold or if they're similar in price.
Try
<Copy Condition="'%(Files.Identity)' == 'C:\MyFile.txt'" .. />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With