forwarding this from another list. Somthing cool you can do with the script task .
--- Begin Message ---
Frederic,

The CreateTask function is mostly used for internal stuff but there is 
no reason why it shouldn't be used in the way you were attempting. I've 
commited a 1 line patch to NAnt that allows a task object to be created 
without requiring associated file and line info. So if you sync the cvs 
tree or get the next nightly from : http://nant.sourceforge.net/builds/ 
it should work. There were a couple of minor fixes needed to get your 
script task working as intended- see below.

   <!-- Build the list of plugins to be built and apeend exec tasks 
accordingly -->
             <script language="C#" failonerror="true">
                 <references>
                     <includes name="System.Xml.dll" asis="true"/>
                 </references>
                 <code><![CDATA[
                 public static void ScriptMain(Project project) {

                     string PluginsPath = 
Path.Combine(project.BaseDirectory, project.Properties["plugins.dir"] );

                     try {

                             System.Xml.XmlDocument TaskDocument = new 
System.Xml.XmlDocument();
                             TaskDocument.LoadXml("<exec 
program=\"notepad\"/>");
                             System.Xml.XmlNode taskNode = 
TaskDocument.SelectSingleNode("exec");
                             SourceForge.NAnt.Task task = 
project.CreateTask(taskNode);
                             task.Execute();

                     } finally {
                     }
                 }
             ]]></code>
             </script>


Ian

> Was the CreatTask function created not for these kinds of things? Of maybe
> It's just there for internal nant use?
> 
> -----Original Message-----
> From: Ian MacLean [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 14, 2003 3:49 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [OT] Nant scripts woes
> 
> 
> Frederic,
> The Xml node not mapped error is because nant maps every node that it
> loads to a line number in the source file for error reporting purposes.
> Since the node you're adding is dynamic and has no mapping against the
> source build file your're seeing this error. There may be a way around
> it though. Let me take a look and get back to you.
> 
> Ian
> 
>  > Hi,
>  >
>  > Is any one in here using Nant? :)
>  >
>  > I need to have a script task with a script that appends exec tasks at
>  > build time.
>  >
>  > Is that possible? There is this project object as a parameter to the
>  > ScriptMain
>  > Function. The CreateTask allways returns something like 'Xml Node not
>  > mapped'
>  >
>  > Can anyone help me get this straight, It's driving me nuts!
>  >
>  > Thx
>  > Frederic
>  >
>  >
>  > Here's what I tired:
>  >
>  >         <!-- Build the list of plugins to be built and apeend exec
>  > tasks
>  > accordingly -->
>  >         <script language="C#">
>  >       
>  >             <references>
>  >                 <includes name="System.Xml.dll" asis="true"/>
>  >             </references>
>  >               
>  >             <code><![CDATA[
>  >          
>  >             public static void ScriptMain(Project project) {
>  >           
>  >                 string PluginsPath =
>  > Path.Combine(project.BaseDirectory,
>  > project.Properties["plugins.dir"] );
>  >               
>  >                 try {
>  >               
>  >                         System.Xml.XmlDocument TaskNode = new
>  > System.Xml.XmlDocument();
>  >                         TaskNode.LoadXml("<exec name=\"notepad\"/>");
>  >                       
>  >                         project.CreateTask(TaskNode);                  
>  >               
>  >               
>  >                 } finally {
>  >                 }
>  >             }
>  >         ]]></code>
>  >         </script>
>  >
>  >
>  > Fr�d�ric Gos
>  > Senior Software Architect
>  > Composite Netsystems
>  >
>  > Phone: +45 35 55 23 52
>  > Mobile: +45 20 91 67 71
>  > ----------------------------------------------------------------------
>  > -
>  > Learn more about Composite on www.composite.net
>  >
>  >
>  > To unsubscribe from this group, send an email to:
>  > [EMAIL PROTECTED]
>  >
>  >
>  >
>  > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
>  > <http://docs.yahoo.com/info/terms/>.
> 
> 
> 
> 
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
> 
>  
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
> 
> 
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
> 
> 
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service 
> <http://docs.yahoo.com/info/terms/>.



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/FpY02D/vN2EAA/xGHJAA/NZFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

--- End Message ---

Reply via email to