[xbuild] Evaluate Import with MSBuildThisFile* properties set.
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / Project.cs
index 9750d831e7a267ca7892b1b80d1f317f274cf2d1..d2f466121212990779e30341db5ba6941c510b23 100644 (file)
@@ -1096,12 +1096,18 @@ namespace Microsoft.Build.BuildEngine {
                        if (evaluate_properties)
                                groupingCollection.Evaluate (EvaluationType.Property);
 
-                       string project_attribute = xmlElement.GetAttribute ("Project");
-                       if (String.IsNullOrEmpty (project_attribute))
-                               throw new InvalidProjectFileException ("The required attribute \"Project\" is missing from element <Import>.");
+                       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));
+                               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)