${b}"> ...">

How to convert if condition to NAnt in MSBuild?

I have an NAnt script as shown below:

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

I want to convert it to an MSBuild script. I found that there are conditions for writing, but it is only used to define a property / element.

Can we write an if condition in MSBuild? Please, help!

+5
source share
1 answer

Each msbuild task has an optional Condition parameter so you can do this:

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

Change: . If you need a condition to perform several tasks, you can repeat the Foreach condition parameter or you can encapsulate the call of several tasks in the target

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

(The <and> characters must be escaped)

+5
source

All Articles