Man - i can't wait until 0.85 is release :)  I'd love to start using functions, but we just can't concider using a nightly for a production buildsserver.

----Original Message Follows----
From: Ian MacLean <[EMAIL PROTECTED]>
To: Ian MacLean <[EMAIL PROTECTED]>
CC: "Price, Henry" <[EMAIL PROTECTED]>,        "'Bob Archer'" <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: Re: [Nant-users] get version from dll?
Date: Sat, 01 May 2004 01:50:20 +0900
actually you can set the properties from the function as well. Like:
<script language="C#" prefix="script" >
    <code><![CDATA[                            [Function("get-file-version")]
        public string GetFileVersion( string file, bool setProperties ) {
                      System.Diagnostics.FileVersionInfo myFileVersionInfo =
            System.Diagnostics.FileVersionInfo.GetVersionInfo(file);
            if ( setProperties ) {
                Project.Properties["dll.majorversion"] = myFileVersionInfo.FileMajorPart.ToString();
                Project.Properties["dll.minorversion"] = myFileVersionInfo.FileMinorPart.ToString();
                Project.Properties["dll.buildversion"] = myFileVersionInfo.FileBuildPart.ToString();
                Project.Properties["dll.privateversion"] = myFileVersionInfo.FilePrivatePart.ToString();
            }
            return myFileVersionInfo.FileVersion;
              }
     ]]></code>
</script>
the advantage of a custom function over a block of script in a target is that you only have to define it once and can then call it for each file you need version info for.
Ian
Ian MacLean wrote:
>This is nice. Better than my assembly specific version.
>
>Note that if you are using a current nightly you can wrap your
>diagnostics code in a custom function definition like:
>
><code><![CDATA[                  [Function("get-file-version")]
>        public string GetFileVersion( string file ) {
>                        System.Diagnostics.FileVersionInfo
>myFileVersionInfo =
>            
>System.Diagnostics.FileVersionInfo.GetVersionInfo(file);
>         return myFileVersionInfo.FileVersion;
>      }
>]]></code>
></script>
>and then call it like:
>
><property name="fileversion"
>value="script::get-file-version('somefile.dll')" />
>
>of course if you need to set properties to the individual version
>components then a custom task is a better option.
>
>Bob,
>You should be able to drop the above code into your build file if
>all you need is the file version as a string.
>
>Ian
>
>
>Price, Henry wrote:
>
>>How about something like this? (off the top of my head and without
>>intellisense :)
>>
>>We've done something similar here - for checking which versions of
>>files are
>>installed etc - had to do it all in script - I've given up on
>>writing custom
>>tasks, they take too long to edit when you need to change stuff :)
>>
>><script language="C#">
>>   <code><![CDATA[
>>    public static void ScriptMain(Project project)
>>    {
>>      System.Diagnostics.FileVersionInfo myFileVersionInfo =
>>System.Diagnostics.FileVersionInfo.GetVersionInfo("path to your
>>dll");
>>      project.Properties["dll.majorversion"] =
>>myFileVersionInfo.FileMajorPart;
>>      project.Properties["dll.minorversion"] =
>>myFileVersionInfo.FileMinorPart;
>>      project.Properties["dll.buildversion"] =
>>myFileVersionInfo.FileBuildPart;
>>      project.Properties["dll.privateversion"] =
>>myFileVersionInfo.FilePrivatePart;
>>    ]]></code>
>>  </script>
>>
>>-----Original Message-----
>>From: Bob Archer [mailto:[EMAIL PROTECTED] Sent: 30 April 2004
>>4:21P
>>To: [EMAIL PROTECTED]
>>Subject: [Nant-users] get version from dll?
>>
>>
>>
>>Hi All,
>>
>>
>>
>>I am creating a build script that deploys our last successful daily
>>build to
>>our QA machine.
>>
>>
>>How could I get the version/build number from a dll? Any ideas? I
>>could get
>>the last build number from the build number file that my version
>>task uses,
>>however, if that build failed it will not be the one in the daily
>>build
>>area.
>>
>>
>>
>>Thanks,
>>
>>Bob
>>
>>
>>
>>
>>
>>"This communication is intended solely for the addressee and is
>>confidential and not for third party unauthorised distribution."
>>
>>
>>
>>
>
>
--
Ian MacLean, Developer, ActiveState, a division of Sophos
http://www.ActiveState.com
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users


FREE pop-up blocking with the new MSN Toolbar – get it now! ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ Nant-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to