How to set 'condition' using a condition stored in a property?

 ̄綄美尐妖づ 提交于 2019-12-11 12:54:44

问题


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!


回答1:


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>

Note that:

  • 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; )


来源:https://stackoverflow.com/questions/2499253/how-to-set-condition-using-a-condition-stored-in-a-property

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