Jeroen,

The <script> is currently not support on Mono. The reason for this is that the <script> task supports C#, VB.NET and JScript.NET, and Mono is still lacking support for JScript.NET (at least in officially released versions).

The built-in properties are documented here : http://nant.sourceforge.net/nightly/help/fundamentals/properties.html

However, most of them will be deprecated in the 0.85 release and have been replaced with functions (as these are much more powerful).

Perhaps we could add support for a version data type in NAnt, and then also support relational operations between instances of that type, but not all "regulars" might like that idea ...

You could then have something like this :

<if test="${assembly::get-version(nant::get-location()) > version::from-string('0.85.1684.0')}">
....
</if>


But this would need to be discussed first ...

Gert

----- Original Message ----- From: "Jeroen Zwartepoorte" <[EMAIL PROTECTED]>
To: "Castro, Edwin Gabriel (Firing Systems Engr.)" <[EMAIL PROTECTED]>
Cc: "Gert Driesen" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, August 13, 2004 8:20 PM
Subject: RE: [Nant-users] checking nant version



Hmm, nant is not recognizing the <script> task:

Invalid element <script>. Unknown task or datatype.

It doesn't seem to matter where i put the <script> task in the build
file. Is this a bug in a recent nightly build? (i'm using
nant-0.85-20040809).

Btw: it seems "nant.version" is a predefined property. So i don't need
the "${assembly::get-version(nant::get-location())}" bit. Are these
properties documented somewhere?

Jeroen

p.s. relevant bits from default.build below (does the greater than sign
in "v1 >= v2" need to be escaped btw?):

   <!-- script hack for checking nant versions -->
   <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>

   <!-- check for pkg-config dependencies and initialize properties -->
   <target name="init" description="initializes build properties">
       <!-- check for an up-to-date nant -->
       <if test="${not(script::version-greater-or-equal(nant.version,
nant.neededversion))}">
           <echo message="MonoDevelop requires nant version
${nant.neededversion} or greater"/>
           <fail message="nant version not supported"/>
       </if>



On Fri, 2004-08-13 at 12:45 -0500, Castro, Edwin Gabriel (Firing Systems
Engr.) wrote:
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