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">

            <code><![CDATA[

                        [Function("getInput")]

                        public static string getInput()

                        {

                                    Console.WriteLine("Enter a string:
");

                                    string s = Console.ReadLine();

 


                                    return s.ToString();

                        }

            ]]></code>

            </script>

                        

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

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

</target>

 

Executing this on my machine produces the following output:

 

C:\>nant -f:test.build getUserInput

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

Copyright (C) 2001-2007 Gerry Shaw

http://nant.sourceforge.net

 

Buildfile: file:///C:/test.build

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.

 

getUserInput:

 

   [script] Scanning assembly "vohtvvkh" for extensions.

Enter a string:

This is a test string!!

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

 

BUILD SUCCEEDED

 

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,

Mike

 

________________________________

From: Parrish, Ken [mailto:kparr...@gomez.com] 
Sent: Tuesday, November 03, 2009 9:34 AM
To: nant-users@lists.sourceforge.net
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!
http://p.sf.net/sfu/devconference
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to