I have written a simple NAnt custom task which I want to create property than
can then be used in my NAnt scripts. My problem is I dont know how to
access this property from my scripts. I have called the task so that it
populated its internal variables and then tried the following to access the
properties from my script
<echo message=${timestamp.basetimestamp}/>
Here is my custom task
namespace NAntTimeStamp
{
[TaskName("timestamp")]
public class NAntTimeStampTask : Task
{
private string t = null;
private string tFile = null;
private string post = null;
private string pre = null;
public void TestTask()
{
ExecuteTask();
}
[TaskAttribute("basetimestamp", Required = false)]
[StringValidator(AllowEmpty = true)]
public string timeStamp
{
get { return t; }
set { t = value; }
}
[TaskAttribute("filetimestamp", Required = false)]
[StringValidator(AllowEmpty = true)]
public string fileTimeStamp
{
get { return tFile; }
set { tFile = value; }
}
[StringValidator(AllowEmpty = true)]
public string postFix
{
get { return post; }
set { post = value; }
}
[TaskAttribute("prefix", Required = false)]
[StringValidator(AllowEmpty = true)]
public string preFix
{
get { return pre; }
set { pre = value; }
}
protected override void ExecuteTask()
{
DateTime now = DateTime.Now;
string current = now.ToString();
tFile = current;
StringBuilder buffer = new StringBuilder();
buffer.Append("v1.");
buffer.Append(String.Format("{0:MM}", now.Month.ToString()));
buffer.Append(".");
buffer.Append(String.Format("{0:dd}", now.Day.ToString()));
buffer.Append(".");
buffer.Append(String.Format("{0:hh}", now.Hour.ToString()));
buffer.Append(String.Format("{0:mm}", now.Minute.ToString()));
buffer.Append(String.Format("{0:ss}", now.Second.ToString()));
t = preFix + buffer + postFix;
}
}
}
--
View this message in context:
http://www.nabble.com/Returning-Values-from-a-Custom-Nant-Task-tf3181447.html#a8828738
Sent from the NAnt - Users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NAnt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nant-users