2007-01-08 Marek Sieradzki <marek.sieradzki@gmail.com>
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / Project.cs
1 //
2 // Project.cs: Project class
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2005 Marek Sieradzki
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 #if NET_2_0
29
30 using System;
31 using System.Collections;
32 using System.Collections.Generic;
33 using System.Collections.Specialized;
34 using System.IO;
35 using System.Text;
36 using System.Xml;
37 using System.Xml.Schema;
38 using Microsoft.Build.Framework;
39 using Mono.XBuild.Framework;
40
41 namespace Microsoft.Build.BuildEngine {
42         public class Project {
43         
44                 bool                            buildEnabled;
45                 Dictionary <string, List <string>>      conditionedProperties;
46                 string[]                        defaultTargets;
47                 Encoding                        encoding;
48                 BuildItemGroup                  evaluatedItems;
49                 BuildItemGroup                  evaluatedItemsIgnoringCondition;
50                 Dictionary <string, BuildItemGroup>     evaluatedItemsByName;
51                 Dictionary <string, BuildItemGroup>     evaluatedItemsByNameIgnoringCondition;
52                 BuildPropertyGroup              evaluatedProperties;
53                 string                          firstTargetName;
54                 string                          fullFileName;
55                 BuildPropertyGroup              globalProperties;
56                 GroupingCollection              groupingCollection;
57                 bool                            isDirty;
58                 bool                            isValidated;
59                 BuildItemGroupCollection        itemGroups;
60                 ImportCollection                imports;
61                 string                          initialTargets;
62                 Engine                          parentEngine;
63                 BuildPropertyGroupCollection    propertyGroups;
64                 string                          schemaFile;
65                 TaskDatabase                    taskDatabase;
66                 TargetCollection                targets;
67                 DateTime                        timeOfLastDirty;
68                 UsingTaskCollection             usingTasks;
69                 XmlDocument                     xmlDocument;
70                 bool                            unloaded;
71
72                 static XmlNamespaceManager      manager;
73                 static string ns = "http://schemas.microsoft.com/developer/msbuild/2003";
74
75                 public Project ()
76                         : this (Engine.GlobalEngine)
77                 {
78                 }
79
80                 public Project (Engine engine)
81                 {
82                         parentEngine  = engine;
83
84                         buildEnabled = ParentEngine.BuildEnabled;
85                         xmlDocument = new XmlDocument ();
86                         xmlDocument.AppendChild (xmlDocument.CreateElement ("Project", XmlNamespace));
87                         xmlDocument.DocumentElement.SetAttribute ("xmlns", ns);
88                         
89                         fullFileName = String.Empty;
90
91                         globalProperties = new BuildPropertyGroup (null, this, null, false);
92                         foreach (BuildProperty bp in parentEngine.GlobalProperties)
93                                 GlobalProperties.AddProperty (bp.Clone (true));
94                         
95                         ProcessXml ();
96                 }
97
98                 [MonoTODO]
99                 public void AddNewImport (string importLocation,
100                                           string importCondition)
101                 {
102                         throw new NotImplementedException ();
103                 }
104
105                 [MonoTODO]
106                 public BuildItem AddNewItem (string itemName,
107                                              string itemInclude)
108                 {
109                         return AddNewItem (itemName, itemInclude, false);
110                 }
111                 
112                 [MonoTODO]
113                 public BuildItem AddNewItem (string itemName,
114                                              string itemInclude,
115                                              bool treatItemIncludeAsLiteral)
116                 {
117                         throw new NotImplementedException ();
118                 }
119
120                 [MonoTODO]
121                 public BuildItemGroup AddNewItemGroup ()
122                 {
123                         throw new NotImplementedException ();
124                 }
125
126                 [MonoTODO]
127                 public BuildPropertyGroup AddNewPropertyGroup (bool insertAtEndOfProject)
128                 {
129                         throw new NotImplementedException ();
130                 }
131                 
132                 [MonoTODO]
133                 public void AddNewUsingTaskFromAssemblyFile (string taskName,
134                                                              string assemblyFile)
135                 {
136                         throw new NotImplementedException ();
137                 }
138                 
139                 [MonoTODO]
140                 public void AddNewUsingTaskFromAssemblyName (string taskName,
141                                                              string assemblyName)
142                 {
143                         throw new NotImplementedException ();
144                 }
145                 
146                 [MonoTODO]
147                 public bool Build ()
148                 {
149                         return true;
150                 }
151                 
152                 [MonoTODO]
153                 public bool Build (string targetName)
154                 {
155                         return Build (new string [1] { targetName });
156                 }
157                 
158                 [MonoTODO]
159                 public bool Build (string[] targetNames)
160                 {
161                         return Build (targetNames, null);
162                 }
163                 
164                 [MonoTODO]
165                 public bool Build (string[] targetNames,
166                                    IDictionary targetOutputs)
167                 {
168                         return Build (targetNames, targetOutputs, BuildSettings.None);
169                 }
170                 
171                 [MonoTODO]
172                 public bool Build (string[] targetNames,
173                                    IDictionary targetOutputs,
174                                    BuildSettings buildFlags)
175                 
176                 {
177                         CheckUnloaded ();
178                         
179                         if (targetNames.Length == 0) {
180                                 if (defaultTargets != null && defaultTargets.Length != 0)
181                                         targetNames = defaultTargets;
182                                 else if (firstTargetName != null)
183                                         targetNames = new string [1] { firstTargetName};
184                                 else
185                                         return false;
186                         }
187                         
188                         foreach (string target in targetNames) {
189                                 if (!targets.Exists (target))
190                                         // FIXME: test if it's logged
191                                         return false;
192                                 
193                                 if (!targets [target].Build ())
194                                         return false;
195                         }
196                                 
197                         return true;
198                 }
199
200                 [MonoTODO]
201                 public string[] GetConditionedPropertyValues (string propertyName)
202                 {
203                         if (conditionedProperties.ContainsKey (propertyName))
204                                 return conditionedProperties [propertyName].ToArray ();
205                         else
206                                 return new string [0];
207                 }
208
209                 public BuildItemGroup GetEvaluatedItemsByName (string itemName)
210                 {
211                         if (evaluatedItemsByName.ContainsKey (itemName))
212                                 return evaluatedItemsByName [itemName];
213                         else
214                                 return new BuildItemGroup ();
215                 }
216
217                 public BuildItemGroup GetEvaluatedItemsByNameIgnoringCondition (string itemName)
218                 {
219                         if (evaluatedItemsByNameIgnoringCondition.ContainsKey (itemName))
220                                 return evaluatedItemsByNameIgnoringCondition [itemName];
221                         else
222                                 return new BuildItemGroup ();
223                 }
224
225                 public string GetEvaluatedProperty (string propertyName)
226                 {
227                         if (propertyName == null)
228                                 throw new ArgumentNullException ("propertyName");
229
230                         BuildProperty bp = evaluatedProperties [propertyName];
231
232                         return bp == null ? null : (string) bp;
233                 }
234
235                 public string GetProjectExtensions (string id)
236                 {
237                         if (id == null || id == String.Empty)
238                                 return String.Empty;
239
240                         XmlNode node = xmlDocument.SelectSingleNode (String.Format ("/tns:Project/tns:ProjectExtensions/tns:{0}", id), XmlNamespaceManager);
241
242                         if (node == null)
243                                 return String.Empty;
244                         else
245                                 return node.InnerXml;
246                 }
247
248
249                 public void Load (string projectFileName)
250                 {
251                         this.fullFileName = Path.GetFullPath (projectFileName);
252                         DoLoad (new StreamReader (projectFileName));
253                 }
254                 
255                 [MonoTODO]
256                 public void Load (TextReader textReader)
257                 {
258                         fullFileName = String.Empty;
259                         DoLoad (textReader);
260                 }
261
262                 public void LoadXml (string projectXml)
263                 {
264                         fullFileName = String.Empty;
265                         DoLoad (new StringReader (projectXml));
266                         MarkProjectAsDirty ();
267                 }
268
269
270                 public void MarkProjectAsDirty ()
271                 {
272                         isDirty = true;
273                         timeOfLastDirty = DateTime.Now;
274                 }
275
276                 [MonoTODO]
277                 public void RemoveAllItemGroups ()
278                 {
279                         throw new NotImplementedException ();
280                 }
281
282                 [MonoTODO]
283                 public void RemoveAllPropertyGroups ()
284                 {
285                         throw new NotImplementedException ();
286                 }
287
288                 [MonoTODO]
289                 public void RemoveItem (BuildItem itemToRemove)
290                 {
291                         throw new NotImplementedException ();
292                 }
293
294                 [MonoTODO]
295                 public void RemoveItemGroup (BuildItemGroup itemGroupToRemove)
296                 {
297                         throw new NotImplementedException ();
298                 }
299                 
300                 [MonoTODO]
301                 // NOTE: does not modify imported projects
302                 public void RemoveItemGroupsWithMatchingCondition (string matchingCondition)
303                 {
304                         throw new NotImplementedException ();
305                 }
306
307                 [MonoTODO]
308                 public void RemoveItemsByName (string itemName)
309                 {
310                         throw new NotImplementedException ();
311                 }
312
313                 [MonoTODO]
314                 public void RemovePropertyGroup (BuildPropertyGroup propertyGroupToRemove)
315                 {
316                         throw new NotImplementedException ();
317                 }
318                 
319                 [MonoTODO]
320                 // NOTE: does not modify imported projects
321                 public void RemovePropertyGroupsWithMatchingCondition (string matchCondition)
322                 {
323                         throw new NotImplementedException ();
324                 }
325
326                 [MonoTODO]
327                 public void ResetBuildStatus ()
328                 {
329                         throw new NotImplementedException ();
330                 }
331
332                 public void Save (string projectFileName)
333                 {
334                         Save (projectFileName, Encoding.Default);
335                 }
336
337                 public void Save (string projectFileName, Encoding encoding)
338                 {
339                         xmlDocument.Save (projectFileName);
340                 }
341
342                 public void Save (TextWriter outTextWriter)
343                 {
344                         xmlDocument.Save (outTextWriter);
345                 }
346
347                 public void SetImportedProperty (string propertyName,
348                                                  string propertyValue,
349                                                  string condition,
350                                                  Project importProject)
351                 {
352                         SetImportedProperty (propertyName, propertyValue, condition, importProject,
353                                 PropertyPosition.UseExistingOrCreateAfterLastPropertyGroup);
354                 }
355
356                 public void SetImportedProperty (string propertyName,
357                                                  string propertyValue,
358                                                  string condition,
359                                                  Project importedProject,
360                                                  PropertyPosition position)
361                 {
362                         SetImportedProperty (propertyName, propertyValue, condition, importedProject,
363                                 PropertyPosition.UseExistingOrCreateAfterLastPropertyGroup, false);
364                 }
365
366                 [MonoTODO]
367                 public void SetImportedProperty (string propertyName,
368                                                  string propertyValue,
369                                                  string condition,
370                                                  Project importedProject,
371                                                  PropertyPosition position,
372                                                  bool treatPropertyValueAsLiteral)
373                 {
374                         throw new NotImplementedException ();
375                 }
376
377                 public void SetProjectExtensions (string id, string xmlText)
378                 {
379                         XmlNode projectExtensions, node;
380
381                         if (id == null || id == String.Empty || xmlText == null)
382                                 return;
383
384                         projectExtensions = xmlDocument.SelectSingleNode ("/tns:Project/tns:ProjectExtensions", XmlNamespaceManager);
385                         
386                         
387                         if (projectExtensions == null) {
388                                 projectExtensions = xmlDocument.CreateElement ("ProjectExtensions", XmlNamespace);
389                                 xmlDocument.DocumentElement.AppendChild (projectExtensions);
390
391                                 node = xmlDocument.CreateElement (id, XmlNamespace);
392                                 node.InnerXml = xmlText;
393                                 projectExtensions.AppendChild (node);
394                         } else {
395                                 node = xmlDocument.SelectSingleNode (String.Format ("/tns:Project/tns:ProjectExtensions/tns:{0}", id), XmlNamespaceManager);
396
397                                 if (node == null) {
398                                         node = xmlDocument.CreateElement (id, XmlNamespace);
399                                         projectExtensions.AppendChild (node);
400                                 }
401                                 
402                                 node.InnerXml = xmlText;
403                                 
404                         }
405
406                         MarkProjectAsDirty ();
407                 }
408                 
409                 [MonoTODO]
410                 public void SetProperty (string propertyName,
411                                          string propertyValue)
412                 {
413                         SetProperty (propertyName, propertyValue, "true",
414                                 PropertyPosition.UseExistingOrCreateAfterLastPropertyGroup, false);
415                 }
416
417                 [MonoTODO]
418                 public void SetProperty (string propertyName,
419                                          string propertyValue,
420                                          string condition)
421                 {
422                         SetProperty (propertyName, propertyValue, condition,
423                                 PropertyPosition.UseExistingOrCreateAfterLastPropertyGroup);
424                 }
425
426                 [MonoTODO]
427                 public void SetProperty (string propertyName,
428                                          string propertyValue,
429                                          string condition,
430                                          PropertyPosition position)
431                 {
432                         SetProperty (propertyName, propertyValue, condition,
433                                 PropertyPosition.UseExistingOrCreateAfterLastPropertyGroup, false);
434                 }
435
436                 [MonoTODO]
437                 public void SetProperty (string propertyName,
438                                          string propertyValue,
439                                          string condition,
440                                          PropertyPosition position,
441                                          bool treatPropertyValueAsLiteral)
442                 {
443                         throw new NotImplementedException ();
444                 }
445
446                 internal void Unload ()
447                 {
448                         unloaded = true;
449                 }
450
451                 internal void CheckUnloaded ()
452                 {
453                         if (unloaded)
454                                 throw new InvalidOperationException ("This project object has been unloaded from the MSBuild engine and is no longer valid.");
455                 }
456                                 
457                 // Does the actual loading.
458                 void DoLoad (TextReader textReader)
459                 {
460                         try {
461                                 ParentEngine.RemoveLoadedProject (this);
462         
463                                 XmlReaderSettings settings = new XmlReaderSettings ();
464         
465                                 if (SchemaFile != null) {
466                                         settings.Schemas.Add (null, SchemaFile);
467                                         settings.ValidationType = ValidationType.Schema;
468                                         settings.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack);
469                                 }
470         
471                                 XmlReader xmlReader = XmlReader.Create (textReader, settings);
472                                 xmlDocument.Load (xmlReader);
473
474                                 if (xmlDocument.DocumentElement.Name != "Project") {
475                                         throw new InvalidProjectFileException (String.Format (
476                                                 "The element <{0}> is unrecognized, or not supported in this context.", xmlDocument.DocumentElement.Name));
477                                 }
478         
479                                 if (xmlDocument.DocumentElement.GetAttribute ("xmlns") != ns) {
480                                         throw new InvalidProjectFileException (
481                                                 @"The default XML namespace of the project must be the MSBuild XML namespace." + 
482                                                 " If the project is authored in the MSBuild 2003 format, please add " +
483                                                 "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" to the <Project> element. " +
484                                                 "If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.  ");
485                                 }
486                                 ProcessXml ();
487                                 ParentEngine.AddLoadedProject (this);
488                         } catch (Exception e) {
489                                 throw new InvalidProjectFileException (e.Message, e);
490                         }
491                 }
492
493                 internal void ProcessXml ()
494                 {
495                         groupingCollection = new GroupingCollection (this);
496                         imports = new ImportCollection (groupingCollection);
497                         usingTasks = new UsingTaskCollection (this);
498                         itemGroups = new BuildItemGroupCollection (groupingCollection);
499                         propertyGroups = new BuildPropertyGroupCollection (groupingCollection);
500                         targets = new TargetCollection (this);
501                         
502                         taskDatabase = new TaskDatabase ();
503                         if (ParentEngine.DefaultTasksRegistered)
504                                 taskDatabase.CopyTasks (ParentEngine.DefaultTasks);     
505
506                         if (xmlDocument.DocumentElement.GetAttributeNode ("DefaultTargets") != null)
507                                 defaultTargets = xmlDocument.DocumentElement.GetAttribute ("DefaultTargets").Split (';');
508                         else
509                                 defaultTargets = new string [0];
510                         
511                         ProcessElements (xmlDocument.DocumentElement, null);
512                         
513                         isDirty = false;
514                         Evaluate ();
515                 }
516                 
517                 internal void ProcessElements (XmlElement rootElement, ImportedProject ip)
518                 {
519                         foreach (XmlNode xn in rootElement.ChildNodes) {
520                                 if (xn is XmlElement) {
521                                         XmlElement xe = (XmlElement) xn;
522                                         switch (xe.Name) {
523                                         case "ProjectExtensions":
524                                                 AddProjectExtensions (xe);
525                                                 break;
526                                         case "Warning":
527                                         case "Message":
528                                         case "Error":
529                                                 AddMessage (xe);
530                                                 break;
531                                         case "Target":
532                                                 AddTarget (xe, ip);
533                                                 break;
534                                         case "UsingTask":
535                                                 AddUsingTask (xe, ip);
536                                                 break;
537                                         case "Import":
538                                                 AddImport (xe, ip);
539                                                 break;
540                                         case "ItemGroup":
541                                                 AddItemGroup (xe, ip);
542                                                 break;
543                                         case "PropertyGroup":
544                                                 AddPropertyGroup (xe, ip);
545                                                 break;
546                                         case  "Choose":
547                                                 AddChoose (xe);
548                                                 break;
549                                         default:
550                                                 throw new InvalidProjectFileException ("Invalid element in project file.");
551                                         }
552                                 }
553                         }
554                 }
555                 
556                 internal void Evaluate ()
557                 {
558                         evaluatedItems = new BuildItemGroup (null, this, null, true);
559                         evaluatedItemsIgnoringCondition = new BuildItemGroup (null, this, null, true);
560                         evaluatedItemsByName = new Dictionary <string, BuildItemGroup> (StringComparer.InvariantCultureIgnoreCase);
561                         evaluatedItemsByNameIgnoringCondition = new Dictionary <string, BuildItemGroup> (StringComparer.InvariantCultureIgnoreCase);
562                         evaluatedProperties = new BuildPropertyGroup (null, null, null, true);
563
564                         InitializeProperties ();
565
566                         groupingCollection.Evaluate ();
567
568                         //FIXME: UsingTasks aren't really evaluated. (shouldn't use expressions or anything)
569                         foreach (UsingTask usingTask in UsingTasks)
570                                 usingTask.Evaluate ();
571                 }
572
573                 void InitializeProperties ()
574                 {
575                         BuildProperty bp;
576
577                         foreach (BuildProperty gp in GlobalProperties) {
578                                 bp = new BuildProperty (gp.Name, gp.Value, PropertyType.Global);
579                                 EvaluatedProperties.AddProperty (bp);
580                         }
581                         
582                         foreach (DictionaryEntry de in Environment.GetEnvironmentVariables ()) {
583                                 bp = new BuildProperty ((string) de.Key, (string) de.Value, PropertyType.Environment);
584                                 EvaluatedProperties.AddProperty (bp);
585                         }
586
587                         bp = new BuildProperty ("MSBuildBinPath", parentEngine.BinPath, PropertyType.Reserved);
588                         EvaluatedProperties.AddProperty (bp);
589                 }
590                 
591                 void AddProjectExtensions (XmlElement xmlElement)
592                 {
593                 }
594                 
595                 void AddMessage (XmlElement xmlElement)
596                 {
597                 }
598                 
599                 void AddTarget (XmlElement xmlElement, ImportedProject importedProject)
600                 {
601                         Target target = new Target (xmlElement, this, importedProject);
602                         targets.AddTarget (target);
603                         
604                         if (firstTargetName == null)
605                                 firstTargetName = target.Name;
606                 }
607                 
608                 void AddUsingTask (XmlElement xmlElement, ImportedProject importedProject)
609                 {
610                         UsingTask usingTask;
611
612                         usingTask = new UsingTask (xmlElement, this, importedProject);
613                         UsingTasks.Add (usingTask);
614                 }
615                 
616                 void AddImport (XmlElement xmlElement, ImportedProject importingProject)
617                 {
618                         Import import;
619                         
620                         import = new Import (xmlElement, this, importingProject);
621                         Imports.Add (import);
622                 }
623                 
624                 void AddItemGroup (XmlElement xmlElement, ImportedProject importedProject)
625                 {
626                         BuildItemGroup big = new BuildItemGroup (xmlElement, this, importedProject, false);
627                         ItemGroups.Add (big);
628                 }
629                 
630                 void AddPropertyGroup (XmlElement xmlElement, ImportedProject importedProject)
631                 {
632                         BuildPropertyGroup bpg = new BuildPropertyGroup (xmlElement, this, importedProject, false);
633                         PropertyGroups.Add (bpg);
634                 }
635                 
636                 void AddChoose (XmlElement xmlElement)
637                 {
638                         BuildChoose bc = new BuildChoose (xmlElement, this);
639                         groupingCollection.Add (bc);
640                         
641                 }
642                 
643                 static void ValidationCallBack (object sender, ValidationEventArgs e)
644                 {
645                         Console.WriteLine ("Validation Error: {0}", e.Message);
646                 }
647                 
648                 public bool BuildEnabled {
649                         get {
650                                 return buildEnabled;
651                         }
652                         set {
653                                 buildEnabled = value;
654                         }
655                 }
656
657                 public Encoding Encoding {
658                         get { return encoding; }
659                 }
660
661                 public string DefaultTargets {
662                         get {
663                                 return xmlDocument.DocumentElement.GetAttribute ("DefaultTargets");
664                         }
665                         set {
666                                 xmlDocument.DocumentElement.SetAttribute ("DefaultTargets", value);
667                                 defaultTargets = value.Split (';');
668                         }
669                 }
670
671                 public BuildItemGroup EvaluatedItems {
672                         get { return evaluatedItems; }
673                 }
674
675                 public BuildItemGroup EvaluatedItemsIgnoringCondition {
676                         get { return evaluatedItemsIgnoringCondition; }
677                 }
678                 
679                 internal IDictionary <string, BuildItemGroup> EvaluatedItemsByName {
680                         get { return evaluatedItemsByName; }
681                 }
682                 
683                 internal IDictionary <string, BuildItemGroup> EvaluatedItemsByNameIgnoringCondition {
684                         get { return evaluatedItemsByNameIgnoringCondition; }
685                 }
686
687                 public BuildPropertyGroup EvaluatedProperties {
688                         get { return evaluatedProperties; }
689                 }
690
691                 public string FullFileName {
692                         get { return fullFileName; }
693                         set { fullFileName = value; }
694                 }
695
696                 public BuildPropertyGroup GlobalProperties {
697                         get { return globalProperties; }
698                         set {
699                                 if (value == null)
700                                         throw new ArgumentNullException ("value");
701                                 
702                                 if (value.FromXml)
703                                         throw new InvalidOperationException ("Can't do that.");
704                                 
705                                 globalProperties = value;
706                         }
707                 }
708
709                 public bool IsDirty {
710                         get { return isDirty; }
711                 }
712
713                 public bool IsValidated {
714                         get { return isValidated; }
715                         set { isValidated = value; }
716                 }
717
718                 public BuildItemGroupCollection ItemGroups {
719                         get { return itemGroups; }
720                 }
721                 
722                 public ImportCollection Imports {
723                         get { return imports; }
724                 }
725                 
726                 public string InitialTargets {
727                         get { return initialTargets; }
728                         set { initialTargets = value; }
729                 }
730
731                 public Engine ParentEngine {
732                         get { return parentEngine; }
733                 }
734
735                 public BuildPropertyGroupCollection PropertyGroups {
736                         get { return propertyGroups; }
737                 }
738
739                 public string SchemaFile {
740                         get { return schemaFile; }
741                         set { schemaFile = value; }
742                 }
743
744                 public TargetCollection Targets {
745                         get { return targets; }
746                 }
747
748                 public DateTime TimeOfLastDirty {
749                         get { return timeOfLastDirty; }
750                 }
751                 
752                 public UsingTaskCollection UsingTasks {
753                         get { return usingTasks; }
754                 }
755
756                 [MonoTODO]
757                 public string Xml {
758                         get { return xmlDocument.InnerXml; }
759                 }
760                 
761                 internal static XmlNamespaceManager XmlNamespaceManager {
762                         get {
763                                 if (manager == null) {
764                                         manager = new XmlNamespaceManager (new NameTable ());
765                                         manager.AddNamespace ("tns", ns);
766                                 }
767                                 
768                                 return manager;
769                         }
770                 }
771                 
772                 internal TaskDatabase TaskDatabase {
773                         get { return taskDatabase; }
774                 }
775                 
776                 internal XmlDocument XmlDocument {
777                         get { return xmlDocument; }
778                 }
779                 
780                 internal static string XmlNamespace {
781                         get { return ns; }
782                 }
783         }
784 }
785
786 #endif