NAnt question: evaluate NAnt expressions in text read from file

I have a NAnt problem: I want to read file from text (actually xmlpeek from an XML document), and evaluate the NAnt expressions defined in the text. So for example:

FILE: Input.txt:
This is a ${word} text!

FILE: PropertyTest.build:
<project default="go">
 <target name="go">
  <property name="word" value="nice"/>
  <loadfile file="input.txt" property="message" />
   <echo message="${message}"/>
 </target>
</project>

CURRENT output:
This is a ${word} text!

WANTED output:
This is a nice text!

Any ideas?

5 Comments

  • what about something like



    build file:



    &lt;project default=&quot;go&quot;&gt;

    &lt;target name=&quot;go&quot;&gt;

    &lt;property name=&quot;word&quot; value=&quot;nice&quot; /&gt;

    &lt;loadfile file=&quot;input.txt&quot; property=&quot;message&quot;&gt;

    &lt;filterchain&gt;

    &lt;replacetokens = &quot;WORD&quot; value=&quot;${word}&quot; /&gt;

    &lt;/filterchain&gt;

    &lt;/loadfile&gt;

    &lt;echo message=&quot;${message}&quot; /&gt;

    &lt;/target&gt;

    &lt;/project&gt;



    input.txt contents:



    This is a @WORD@ text!

  • That works, but the problem is that I would like to evaluate ANY expression in the current context, so also things like ${environment::get-machine-name()}

  • so you want to put the netbios name in some kind of config file right? ;)



    then leave out the property tag and replace



    &lt;replacetokens = &quot;WORD&quot; value=&quot;${word}&quot; /&gt;



    with



    &lt;replacetokens=&quot;MACHINENAME&quot; value=&quot;${environment::get-machine-name()}&quot; /&gt;



    and put the token MACHINENAME somewhere in your text or xml file:



    e.g. &lt;server&gt;@MACHINENAME@&lt;/server&gt;



    That should do the trick :)

  • Those are just examples... I want to be able to resolve ANY expression. Ok, an example you can't handle using your approach;-)



    input.txt contains:



    Addition is ${propertyA + propertyB}



    Where propertyA and propertyB are defined in the current context... Please no more token replacements;-)

  • Internet's premiere source for prom dresses, bridesmaid dresses, prom gowns,bridesmaid gowns,bridal gown,wedding gown and flowergirl dresses at discount prices. Most prom dresses and prom gowns are hand-made and hand-beaded individually and are shipped after two days of processing time.

Comments have been disabled for this content.