Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

msbuild

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!

like image 505
Nam G VU Avatar asked Mar 19 '10 14:03

Nam G VU


1 Answers

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)

like image 66
Julien Hoarau Avatar answered Oct 24 '22 14:10

Julien Hoarau