+ return Expression.ParseAs<string> (file, ParseOptions.Split, project);
+ }
+
+ string GetFullPath ()
+ {
+ string file = EvaluatedProjectPath;
+ if (!Path.IsPathRooted (file) && !String.IsNullOrEmpty (ContainedInProjectFileName))
+ file = Path.Combine (Path.GetDirectoryName (ContainedInProjectFileName), file);
+
+ return MSBuildUtils.FromMSBuildPath (file);
+ }
+
+ // For every extension path, in order, finds suitable
+ // import filename(s) matching the Import, and calls
+ // @func with them
+ //
+ // func: bool func(importPath, from_source_msg)
+ //
+ // If for an extension path, atleast one file gets imported,
+ // then it stops at that.
+ // So, in case imports like "$(MSBuildExtensionsPath)\foo\*",
+ // for every extension path, it will try to import the "foo\*",
+ // and if atleast one file gets successfully imported, then it
+ // stops at that
+ internal static void ForEachExtensionPathTillFound (XmlElement xmlElement, Project project, ImportedProject importingProject,
+ Func<string, string, bool> func)
+ {
+ string project_attribute = xmlElement.GetAttribute ("Project");
+ string condition_attribute = xmlElement.GetAttribute ("Condition");
+
+ bool has_extn_ref = project_attribute.IndexOf ("$(MSBuildExtensionsPath)") >= 0 ||
+ project_attribute.IndexOf ("$(MSBuildExtensionsPath32)") >= 0 ||
+ project_attribute.IndexOf ("$(MSBuildExtensionsPath64)") >= 0;
+
+ string importingFile = importingProject != null ? importingProject.FullFileName : project.FullFileName;
+ DirectoryInfo base_dir_info = null;
+ if (!String.IsNullOrEmpty (importingFile))
+ base_dir_info = new DirectoryInfo (Path.GetDirectoryName (importingFile));
+ else
+ base_dir_info = new DirectoryInfo (Directory.GetCurrentDirectory ());
+
+ IEnumerable<string> extn_paths = has_extn_ref ? GetExtensionPaths (project) : new string [] {null};
+ try {
+ foreach (string path in extn_paths) {
+ string extn_msg = null;
+ if (has_extn_ref) {
+ project.SetExtensionsPathProperties (path);
+ extn_msg = "from extension path " + path;
+ }
+
+ // do this after setting new Extension properties, as condition might
+ // reference it
+ if (!ConditionParser.ParseAndEvaluate (condition_attribute, project)) {
+ project.ParentEngine.LogMessage (MessageImportance.Low,
+ "{0}: Not importing '{1}' project as the condition '{2}' is false",
+ importingFile, project_attribute, condition_attribute);
+ continue;
+ }