+ // eval all the properties etc till the import
+ if (evaluate_properties)
+ groupingCollection.Evaluate (EvaluationType.Property);
+
+ try {
+ PushThisFileProperty (importingProject != null ? importingProject.FullFileName : FullFileName);
+
+ string project_attribute = xmlElement.GetAttribute ("Project");
+ if (String.IsNullOrEmpty (project_attribute))
+ throw new InvalidProjectFileException ("The required attribute \"Project\" is missing from element <Import>.");
+
+ Import.ForEachExtensionPathTillFound (xmlElement, this, importingProject,
+ (importPath, from_source_msg) => AddSingleImport (xmlElement, importPath, importingProject, from_source_msg));
+ } finally {
+ PopThisFileProperty ();
+ }
+ }
+
+ bool AddSingleImport (XmlElement xmlElement, string projectPath, ImportedProject importingProject, string from_source_msg)
+ {
+ Import import = new Import (xmlElement, projectPath, this, importingProject);
+ if (!ConditionParser.ParseAndEvaluate (import.Condition, this)) {
+ ParentEngine.LogMessage (MessageImportance.Low,
+ "Not importing project '{0}' as the condition '{1}' is false",
+ import.ProjectPath, import.Condition);
+ return false;
+ }
+
+ Import existingImport;
+ if (Imports.TryGetImport (import, out existingImport)) {
+ if (importingProject == null)
+ LogWarning (fullFileName,
+ "Cannot import project '{0}' again. It was already imported by " +
+ "'{1}'. Ignoring.",
+ projectPath, existingImport.ContainedInProjectFileName);
+ else
+ LogWarning (importingProject != null ? importingProject.FullFileName : fullFileName,
+ "A circular reference was found involving the import of '{0}'. " +
+ "It was earlier imported by '{1}'. Only " +
+ "the first import of this file will be used, ignoring others.",
+ import.EvaluatedProjectPath, existingImport.ContainedInProjectFileName);
+
+ return false;
+ }
+
+ if (String.Compare (fullFileName, import.EvaluatedProjectPath) == 0) {
+ LogWarning (importingProject != null ? importingProject.FullFileName : fullFileName,
+ "The main project file was imported here, which creates a circular " +
+ "reference. Ignoring this import.");
+
+ return false;
+ }
+