views:

302

answers:

1

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  A: 

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; )
Todd
I agree with you. In addition to note, I put "1 < 2" into property aa and see that the condition doesn't work!So what can we do to have the codition stored in a property? I try to escape < one more time, i.e. "1 %26lt%3B 2" is put into aa, but it is not accepted either. I give up :(
Nam Gi VU