Good Afternoon Folks,


I was just playing around with this and I was able to do it with a C#
script function in a target:


<target name="getUserInput">

<script language="C#" prefix="build">



                        public static string getInput()


                                    Console.WriteLine("Enter a string:

                                    string s = Console.ReadLine();


                                    return s.ToString();





            <property name="_str" value="${build::getInput()}" />

            <echo message="----> Input String: ${_str}" />



Executing this on my machine produces the following output:


C:\>nant getUserInput

NAnt 0.86 (Build 0.86.2898.0; beta1; 12/8/2007)

Copyright (C) 2001-2007 Gerry Shaw


Buildfile: file:///C:/

Target framework: Microsoft .NET Framework 3.5

Target(s) specified: getUserInput


[loadtasks] Scanning assembly "NAnt.Contrib.Tasks" for extensions.

[loadtasks] Scanning assembly "broloco.NAntTasks" for extensions.

   [script] Scanning assembly "cb5myvqk" for extensions.




   [script] Scanning assembly "vohtvvkh" for extensions.

Enter a string:

This is a test string!!

     [echo] ----> Input String: This is a test string!!




Total time: 8.4 seconds.


This stores the input into a property and you can do whatever you like
with it after that.


I hope this helps,




From: Parrish, Ken [] 
Sent: Tuesday, November 03, 2009 9:34 AM
Subject: [NAnt-users] Input prompting ...


Nant Users,


Is there a task that can be used to prompt a user for input of a
property?  I'd like to design some tasks which will prompt the user for
input of a property if the property was not specified on the command
line.  I looked in both Nant and NantContrib and didn't see anything.
Am I missing something?


Ken Parrish

Gomez, Inc.

Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
NAnt-users mailing list

Reply via email to