Thanks Troy, I wasn't aware that I could write a custom task using the script element. very cool, none the less...
Jim > James Geurts wrote: >> Is there a way to explicitly call a function? >> >> For example, I created a function similar to the one below >> and I would like to call it occasionally in my build file: > > James, > > You can call a function as part of an expression, > ${function-prefix::function-name(...)} > >> <script language="C#" prefix="file" > >> <code><![CDATA[ >> >> [Function("create-file")] >> public static void CreateFile(string filename) { >> // Create a random file >> File.Create(filename); >> } >> ]]></code> >> </script> > > I'm not sure this really fits the role of function... functions > certainly perform operations, but their purpose is to return a result. > If a particular operation doesn't have a natural concept of a > "returning a result", then perhaps it should be defined as a task: > > <script language="C#"> > <code><![CDATA[ > [TaskName("create-file")] > public class CreateFile : Task { > [TaskAttribute("filename")] > public FileInfo Filename { > get { return _filename; } > set { _filename = value; } > } private FileInfo _filename; > > public override void ExecuteTask() { > File.Create(Filename); > } > } > ]]></code> > </script> > > > You can then call your shiny new task anywhere you'd normally use a > task: > <create-file filename="foo.txt" /> > > > > Disclaimer Message: > > This message contains confidential information and is intended only for > the individual(s) named. If you are not the named addressee you should > not disseminate, distribute or copy this e-mail. Please immediately > delete it and all copies of it from your system, destroy any hard > copies of it, and notify the sender. E-mail transmission cannot be > guaranteed to be secure or error-free as information could be > intercepted, corrupted, lost, destroyed, arrive late or incomplete, or > contain viruses. To the maximum extent permitted by law, Immersive > Technologies Pty. Ltd. does not accept liability for any errors or > omissions in the contents of this message which arise as a result of > e-mail transmission. ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ Nant-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/nant-users