How to convert 'if' condition in NAnt into MSBuild?

msbuild

Solution

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)

Problem

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!

Original source