Domanda

Nel mio script Nant vorrei confrontare un valore di proprietà con una stringa nota. Dopo aver letto le Nant Expressions documentazione ritenevo che sarei stato in grado di fare un confronto "==" di base da valutare come un valore booleano.

Tuttavia, dato il blocco di script:

<if test="${target.env} == Dev">
  <echo message="***** You are using DEV"/>
</if>

Quando eseguito ricevo il seguente errore:

'Dev == Dev' is not a valid value for attribute 'test' of <if ... />.
    Cannot resolve 'Dev == Dev' to boolean value.
    String was not recognized as a valid Boolean.

Sembra che dovrebbe essere semplice (e probabilmente lo è). Come faccio a confrontare due stringhe o proprietà in Nant per valutarle come booleane?

È stato utile?

Soluzione

Vedi qui per esempio. per es.

<if test="${target.env}=='Dev'">
    ....
</if>

Altri suggerimenti

Funziona anche se hai l'intera espressione tra le parentesi graffe:

<if test="${target.env =='Dev'}">
    ....
</if>

se si desidera confrontare due variabili $ {test.var1} e $ {test.var2} poi

<if test="${test.var1 == test.var2}">
....
</if>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top