tags:

views:

41

answers:

1

I have a NAnt script like below:

<if test="${a}>${b}">      
  <call target="target"/>
</if>

What I want is to convert it into MSBuild script. I found that there is tag to write conditions but it is only used for defining property/item.

Can we write 'if' condition in MSBuild? Please help!

+1  A: 

Every msbuild task have an optional Condition parameter so you could do this:

<CallTarget Targets="target" Condition="${a} &gt; ${b}"/>

Edit: If you need a condition to execute multiple task, you could repeat the Condition parameter foreach task or you could encapsulate the multiple task call in a target

<Target Name="MultipleCall" Condition="${a} &gt; ${b}">
  <CallTarget Targets="targetA"/>
  <CallTarget Targets="targetB"/>
</Target>

(The characters < and > must be escaped)

madgnome
Thanks madgnome!But what if we need a condition to execute multiple tasks:<if test="${a}>${b}"> <call target="target1"/> <call target="target1"/> ... <call target="targetN"/></if>Hope to hear from you.
Nam Gi VU