I searched for a way for an included build file to somehow
determine its location (i.e., the full path to itself, not
the project's top-level build file).  There may be easier
way that I missed but I figured out how to do it with this
custom task:

    <script language="C#" prefix="test" >
        <code>
            <![CDATA[
                [TaskName("getbuildfile")]
                public class GetBuildFileTask : Task {
                    #region Private Instance Fields

                    private string _propertyName;

                    #endregion Private Instance Fields

                    #region Public Instance Properties

                    /// <summary>
                    /// <para>
                    /// The name of a property in which the
                    /// full path of the current build file
                    /// should be stored.
                    /// </para>
                    /// </summary>
                    [TaskAttribute("property", Required=true)]
                    [StringValidator(AllowEmpty=false)]
                    public string PropertyName {
                        get { return _propertyName; }
                        set { _propertyName = value; }
                    }

                    #endregion Public Instance Properties

                    #region Override implementation of Task

                    protected override void ExecuteTask() {
                        Properties[PropertyName] = Location.FileName;
                    }

                    #endregion Override implementation of Task
                }
            ]]>
        </code>
    </script>

An example of using this task:

  <getbuildfile property="current-build-file"/>
  <echo message="current build file = ${current-build-file}"/>

Jimm



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NAnt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to