${deployErrors} populated from the regu...">

NAnt: cannot resolve boolean

<if test="${deployErrors} &gt; 0"> <fail message="MSDeploy failed" /> </if> 

${deployErrors} populated from the regular expression capture group and has either a numeric value or an empty string. How to check if it is more than 0 in NAnt if block? Here's the error I get if deployment errors contain "1"

'1> 0' is not a valid value for the attribute 'test' of. Cannot resolve '1> 0' for boolean value. The string was not recognized as a valid boolean.

+6
source share
3 answers

I have not tried, but I think you need all your expression in braces:

<if test="${deployErrors > 0}">

See also the second example on the documentation page.

Update from OP :

This worked:

 <if test="${deployErrors != ''}"> 
+7
source

If you need to do something with the actual numeric value, you can do something like this:

 <if test="${int::parse('0' + deployErrors) > 10}"> 
+4
source

Like Trystan's answer is to parse a string on bool, for a string, for example. true false

 <if test="${bool::parse(isEnabled)}"> 

From http://nant.sourceforge.net/release/0.85/help/functions/bool.parse.html

0
source

Source: https://habr.com/ru/post/887347/


All Articles