Merge pull request #1508 from slluis/fix-20966
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / Project.cs
index c22b8c749c916f44f4fecba2b1d3501143129ef4..005752baf98e12f541683c8aa9f258b6a7d03354 100644 (file)
@@ -323,9 +323,7 @@ namespace Microsoft.Build.BuildEngine {
                                Reevaluate ();
                        }
 
-#if NET_4_0
                        ProcessBeforeAndAfterTargets ();
-#endif
 
                        if (targetNames == null || targetNames.Length == 0) {
                                if (defaultTargets != null && defaultTargets.Length != 0) {
@@ -404,7 +402,6 @@ namespace Microsoft.Build.BuildEngine {
                        return sb.ToString ();
                }
 
-#if NET_4_0
                void ProcessBeforeAndAfterTargets ()
                {
                        var beforeTable = Targets.AsIEnumerable ()
@@ -440,7 +437,6 @@ namespace Microsoft.Build.BuildEngine {
                        expr.Parse (targets, ParseOptions.AllowItemsNoMetadataAndSplit);
                        return (string []) expr.ConvertTo (this, typeof (string []));
                }
-#endif
 
                [MonoTODO]
                public string [] GetConditionedPropertyValues (string propertyName)
@@ -950,8 +946,12 @@ namespace Microsoft.Build.BuildEngine {
                                        case  "Choose":
                                                AddChoose (xe, ip);
                                                break;
+                                       case "ItemDefinitionGroup":
+                                               AddItemDefinitionGroup (xe);
+                                               break;
                                        default:
-                                               throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file '{1}'.", xe.Name, ip.FullFileName));
+                                               var pf = ip == null ? null : string.Format (" '{0}'", ip.FullFileName);
+                                               throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file{1}.", xe.Name, pf));
                                        }
                                }
                        }
@@ -1119,8 +1119,7 @@ namespace Microsoft.Build.BuildEngine {
                {
                        // eval all the properties etc till the import
                        if (evaluate_properties) {
-                               groupingCollection.Evaluate (EvaluationType.Property);
-                               groupingCollection.Evaluate (EvaluationType.Choose);
+                               groupingCollection.Evaluate (EvaluationType.Property | EvaluationType.Choose);
                        }
                        try {
                                PushThisFileProperty (importingProject != null ? importingProject.FullFileName : FullFileName);
@@ -1140,8 +1139,7 @@ namespace Microsoft.Build.BuildEngine {
                {
                        // eval all the properties etc till the import group
                        if (evaluate_properties) {
-                               groupingCollection.Evaluate (EvaluationType.Property);
-                               groupingCollection.Evaluate (EvaluationType.Choose);
+                               groupingCollection.Evaluate (EvaluationType.Property | EvaluationType.Choose);
                        }
                        string condition_attribute = xmlElement.GetAttribute ("Condition");
                        if (!ConditionParser.ParseAndEvaluate (condition_attribute, this))
@@ -1160,6 +1158,17 @@ namespace Microsoft.Build.BuildEngine {
                        }
                }
 
+               void AddItemDefinitionGroup (XmlElement xmlElement)
+               {
+                       string condition_attribute = xmlElement.GetAttribute ("Condition");
+                       if (!ConditionParser.ParseAndEvaluate (condition_attribute, this))
+                               return;
+
+                       foreach (XmlNode xn in xmlElement.ChildNodes) {
+                               // TODO: Add all nodes to some internal dictionary?
+                       }
+               }
+
                bool AddSingleImport (XmlElement xmlElement, string projectPath, ImportedProject importingProject, string from_source_msg)
                {
                        Import import = new Import (xmlElement, projectPath, this, importingProject);
@@ -1416,6 +1425,10 @@ namespace Microsoft.Build.BuildEngine {
                        return default (T);
                }
 
+               internal string ThisFileFullPath {
+                       get { return this_file_property_stack.Peek (); }
+               }
+
                // Used for MSBuild*This* set of properties
                internal void PushThisFileProperty (string full_filename)
                {