How do I do a MSBuild Condition testing if an ItemGroup contains an item?

点点圈 提交于 2019-12-04 16:23:58

问题


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.


回答1:


Try

<Copy Condition="'%(Files.Identity)' == 'C:\MyFile.txt'" .. />



来源:https://stackoverflow.com/questions/7594366/how-do-i-do-a-msbuild-condition-testing-if-an-itemgroup-contains-an-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!