如何使用存储在属性中的条件设置“条件"? [英] How to set 'condition' using a condition stored in a property?

查看:71
本文介绍了如何使用存储在属性中的条件设置“条件"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个条件'a == 1'存储在$(c)属性中,我想将其用作任务消息的条件,如以下代码所示:

I have a condition such as 'a==1' stored in property $(c) and I wanna used it as the condition for task Message like below code:

  <PropertyGroup>
    <aa>1>2</aa>
  </PropertyGroup>

  <Target Name="t">
    <Message Text="122333" Condition="$(aa)" />
  </Target>

引发错误! 那么,我该怎么办呢?请帮忙!

Error was raised! So, how can I do it? Please help!

推荐答案

您可以轻松地使用属性值来评估条件.这是一个示例:

You can easily use property values for evaluating conditions. Here is an example:

<PropertyGroup>
    <aa>1</aa>
</PropertyGroup>

<Target Name="Build">
    <Message Text="Some text" Condition=" $(aa) &lt; 2 " />
</Target>

请注意:

  • 属性值是字符串,您必须在Condition属性中评估条件.有关评估条件的信息,请参见 MSDN文档.
  • 您必须转义XML字符(将<替换为&lt;)
  • Property values are strings, you must evaluate the condition in the Condition attribute. See MSDN Docs on evaluating conditions.
  • You must escape XML characters (replace < with &lt; )

这篇关于如何使用存储在属性中的条件设置“条件"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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