I would recommend that you use the <script> task to create your own
custom function taking two strings and returning a boolean. You can then
use the System.Version class to actually do the comparison. Something
like this:

<script language="C#">
  <code><![CDATA[
    [Function("version-greater-or-equal")]
    public bool VersionGreaterOrEqual(string version1, string version2)
    {
      Version v1 = new Version(version1);
      Version v2 = new Version(version2);
      return v1 >= v2;
    }
  ]]></code>
</script>

You can then call it like this:

<property name="nant.version" value="0.85.1684.0"/>
<property name="nant.currentversion"
value="${assembly::get-version(nant::get-location())}"/>

<if test="${script::version-greater-or-equal(nant.currentversion,
nant.version)}">
  <!-- Do something -->
</if>

I'm sure there are other ways too!

--
Edwin G. Castro
Firing Systems Engineer
[EMAIL PROTECTED]
 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeroen
Zwartepoorte
Sent: Friday, August 13, 2004 8:26 AM
To: Gert Driesen
Cc: [EMAIL PROTECTED]
Subject: Re: [Nant-users] checking nant version

Hi Gert,

Thanks for the quick reply. Still have a question though:

How do i actually check if the current nant version is >= than the
version i need?

I now have this:

<property name="nant.version" value="0.85.1684.0"/>

and

<property name="nant.currentversion" value="${assembly::get-version
(nant::get-location())}"/>

How do i compare these two values? It looks like i could extract the
major, minor, build and revision numbers using the version::get-*
functions, but i still need some sort of string::compare function in
order to actually compare them...

How do i do this? (i don't see any functions in the docs which support
this)

Thanks,

Jeroen

On Fri, 2004-08-13 at 19:06 +0200, Gert Driesen wrote:
> ----- Original Message -----
> From: "Jeroen Zwartepoorte" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, August 13, 2004 4:28 PM
> Subject: [Nant-users] checking nant version
> 
> 
> > Hi,
> >
> > Is there some example nant XML that checks that nant is actually 
> > able to build the project in question? So "nant.version >= 
> > 0.85-20040810" for example? So you can tell the user that he has to 
> > upgrade his nant if he wants to build the project.
> 
> You can use assembly::get-version(nant::get-location()) to get the 
> full version of NAnt.
> 
> > Seems very useful to me when you're using the latest stuff like 
> > filterchains. Also prevents a lot of possible FAQ from appearing on
irc.
> 
> I agree. We'll need to think of a more generic way to accomplish this.
> 
> > btw: do the nant devs hang around on irc? If so, which server and 
> > what channel?
> 
> I hang around on the #mono channel on ircd.gimp.org
> 
> Gert
> 
> 



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save
50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to