OK... so what am I doing wrong... I get the following error:
C:\nant\qa.build(22,3):
Function call failed.
Expression:
${script::get-file-version('\\devevolution\C$\DailyBuild\bin\Geac.Fi
nancials.Business.dll')}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^
\\devevolution\C$\DailyBuild\bin\Geac.Financials.Business.dll
I tried it with an without escaping the back slashes. Here is the
relevant portion from my build file:
<property name="sys.version"
value="${script::get-file-version('\\devevolution\C$\DailyBuild\bin\Geac
.Financials.Business.dll')}" />
<!-- Get Version -->
<script language="C#" prefix="script">
<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>
-----Original Message-----
From: Ian MacLean [mailto:[EMAIL PROTECTED]
Sent: Friday, April 30, 2004 12:50 PM
To: Ian MacLean
Cc: Price, Henry; Bob Archer; [EMAIL PROTECTED]
Subject: Re: [Nant-users] get version from dll?
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_id149&alloc_id�66&op=click
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users