My understanding is that there is no built in way to do this, however,
the following script will help

                <script language="C#">
                <code>
                <![CDATA[
                public static void ScriptMain(Project project)
                {
                        Assembly a =
Assembly.LoadFrom(project.BaseDirectory +
"\\website\\bin\\MyAssembly.dll");
                        project.Properties["project.version"] =
a.GetName().Version.ToString();
                }

                ]]>
                </code>
                </script> 

You can inject this right after your <target> element and then the
"project.version" property will be set like you need below

-----Original Message-----
From: Geurts, James [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 27, 2003 3:01 PM
To: '[EMAIL PROTECTED]'

Is there a fairly simple way to get a project's version?  Example, I
want to get the value of the project.version property in the NAnt.build
file.

This is the code that I have currently, but it doesn't recognize
project.version as an object.


<script language="C#">
<code><![CDATA[
public static void ScriptMain(Project project) {
   string nantPath = Path.Combine(project.BaseDirectory,
project.Properties["nant.dir"]);
   string nantBuildFile = Path.Combine(nantPath, "NAnt.build");
   Project nantProject = new Project(nantBuildFile, false);
   
 
Console.WriteLine(nantProject.Properties["project.version"].ToString());
}
]]></code>
</script>


-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users



-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to