如果ItemGroup包含项目,如何进行MSBuild条件测试? [英] How do I do a MSBuild Condition testing if an ItemGroup contains an item?

查看:91
本文介绍了如果ItemGroup包含项目,如何进行MSBuild条件测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该很简单,但是我找不到执行该操作的方法(或者也许是不可能的.)

This should be simple, but I can't find how to do this (or maybe it's not possible).

在MSBuild中,我有一个ItemGroup,它是文件列表. 我只想在该ItemGroup中有特定文件的情况下执行任务

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

类似的东西:

<Copy Condition="@(Files) <contains> C:\MyFile.txt" .... />

有什么办法吗?最好不要编写自定义任务.

Any way to do this? Preferably without writing a custom task.

文件列表仅与条件有关.否则,它与任务无关.

The list of files is only to do with the condition. Otherwise it has no relation to the task.

推荐答案

尝试

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

这篇关于如果ItemGroup包含项目,如何进行MSBuild条件测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆