Brian,

There isn't any built-in way to evaluate the properties that I could see.

I wrote the following script, a while back, to do what you're reqesting.

Call it as follows:

            <property name="x" value="${dbs::expandValue(y,5)}" />

Where  y is a property with unevaluated properties
        5 is the number of times to recurse and re-evaluate the expression

Or your example:         

        <property name="_message" value="${dbs::expandValue(message,1)}"
dynamic="false" />

I hope this helps,
Noel


    <script language="C#" prefix="dbs" mainclass="dbsHelper" >
        <code>
            <![CDATA[
                [Function("expandValue")]
                public static string expandValue(string value, int depth)
                {
                    return dbsHelper.expandValue(value, depth);
                }
                
                class dbsHelper 
                {
                    static Project _project;
                    
                    public static void ScriptMain(Project project) 
                    {
                        _project = project;
                    }
                    
                    public static string expandValue(string value, int
depth)
                    {
                        if (value.IndexOf('$') < 0 || depth == 0)
                            return value;
                            
                        value = _project.ExpandProperties(value,
Location.UnknownLocation);
                        
                        if (depth > 0)
                            value = expandValue(value, depth-1);
                            
                        return value;
                    }
                }
            ]]>
        </code>
    </script>




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Brian Adams
Sent: Thursday, March 16, 2006 4:57 PM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] Want to force expansion of properties in a string

I have a nant script that generates messages.  I want to pass in the
message place holders for the properties from the command-line along
with the properties values.  For instance:

nant -buildfile:test.build -D:message="mything's value=${mything}"
-D:mything=12345

given the following project:

<project name="test.build" xmlns="http://nant.sf.net/schemas/nant.xsd";>

<target name="test" >
   <property name="mything" value="" />
       <property name="_message" value="${message}" dynamic="false" />
   <echo message="${_message}" />
   </target>
</project>

should produce the resulting string "mything's value=12345" from my
echo statement.


Instead I am getting "mything's value=${mything}".  Is there a way to
force the property in the string to be expanded?


-------------------------------------------------------
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=k&kid0944&bid$1720&dat1642
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users



-------------------------------------------------------
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&kid0944&bid$1720&dat1642
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to