Bugs item #1113857, was opened at 2005-02-01 10:31 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=402868&aid=1113857&group_id=31650
Category: None Group: 0.85 Status: Open Resolution: None Priority: 5 Submitted By: Alex Hildyard (ahildyard) Assigned to: Nobody/Anonymous (nobody) Summary: Project.Document object doesn't reflect buildfile includes Initial Comment: Hi, Many of my NAnt scripts combine "static" NAnt targets with additional data that is added dynamically as the build script executes. For example, I have some boilerplate code to perform NDoc generation, produce NUnit reports, etc. This boilerplate code has a blank <fileset>, since I can't know in advance what assemblies I'll want to test, document, etc. The assembly set on which I perform each of these tasks is generated automatically by parsing the solution file and the project files it references, grabbing the project's XML document object, and then importing new nodes into the document. I find this an effective technique, and it allows me to build a wide range of different solutions using the same generic build script. However, I could do a lot more with it if the project document were updated with any additional targets included as a result of an include/buildfile task. To illustrate what I mean, I've appended a couple of files below. It's basically a project file with a single target ("report"), which includes a second build file with two further targets ("additional- target-1", "additional-target-2"). When the "report" task executes, it's no surprise that the additional targets have been included in the project, so iterating through project.Targets gives the expected result of 3 targets. However, the project's XML document hasn't imported the new targets, so it's impossible to gain a reference on them in order to insert nodes, etc. I find this behaviour inconsistent (and somewhat frustrating!) Has anyone got any comments on this? Ideally, I'd like to see project.Document always reflecting the "complete" project's XML, which means merging in any additional targets at the time buildfile includes get processed. This way, I wouldn't have to distinguish between targets which exist in the "main" project and those which are added as a result of an "include" directive. Regards, Alex Hildyard -------------------------- --- FILE: object-model.xml --- <?xml version="1.0" encoding="utf-8" ?> <project name="object-model-test" default="report"> <include buildfile="other-targets.xml"/> <target name="report"> <script language="C#"> <code><![CDATA [ public static void ScriptMain(Project project) { foreach (NAnt.Core.Target target in project.Targets) { Console.WriteLine("Found target: {0}", target.Name); } foreach (System.Xml.XmlNode node in project.Document.SelectNodes("//target")) { Console.WriteLine("Document target: {0}", node.Attributes["name"].Value); } } ]]></code> </script> </target> </project> --- FILE: other-targets.xml --- <?xml version="1.0" encoding="utf-8" ?> <project name="other-targets"> <target name="additional-target-1"/> <target name="additional-target-2"/> </project> ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=402868&aid=1113857&group_id=31650 ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ nant-developers mailing list nant-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nant-developers