Merge pull request #485 from mtausig/master
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / TaskEngine.cs
index 696ffbeedfbf9f646935fad6697756a372835d2b..335c66b459ac232976876bd4059ad96ea04a1376 100644 (file)
@@ -27,8 +27,6 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-#if NET_2_0
-
 using System;
 using System.Collections.Generic;
 using System.Collections.Specialized;
@@ -82,7 +80,7 @@ namespace Microsoft.Build.BuildEngine {
                        this.task = task;
                        this.taskElement = taskElement;
                        this.taskType = taskType;
-                       values = new Dictionary <string, object> (StringComparer.InvariantCultureIgnoreCase);
+                       values = new Dictionary <string, object> (StringComparer.OrdinalIgnoreCase);
                        
                        foreach (KeyValuePair <string, string> de in parameters) {
                                currentProperty = taskType.GetProperty (de.Key, BindingFlags.Public | BindingFlags.Instance
@@ -177,10 +175,6 @@ namespace Microsoft.Build.BuildEngine {
                                        throw new InvalidProjectFileException ("This is not output property.");
                                
                                o = propertyInfo.GetValue (task, null);
-                               // FIXME: maybe we should throw an exception here?
-                               if (o == null)
-                                       continue;
-                               
                                if (itemName != String.Empty) {
                                        PublishItemGroup (propertyInfo, o, itemName);
                                } else {
@@ -198,7 +192,19 @@ namespace Microsoft.Build.BuildEngine {
                                              object o,
                                              string propertyName)
                {
-                       BuildProperty bp = ChangeType.ToBuildProperty (o, propertyInfo.PropertyType, propertyName);
+                       if (o == null) {
+                               parentProject.EvaluatedProperties.RemoveProperty (propertyName);
+                               return;
+                       }
+
+                       BuildProperty bp;
+                       try {
+                               bp = ChangeType.ToBuildProperty (o, propertyInfo.PropertyType, propertyName);
+                       } catch (Exception e) {
+                               throw new Exception (String.Format ("Error publishing Output from task property '{0} {1}' to property named '{2}' : {3}",
+                                                       propertyInfo.PropertyType, propertyInfo.Name, propertyName, e.Message),
+                                                       e);
+                       }
                        parentProject.EvaluatedProperties.AddProperty (bp);
                }
 
@@ -207,7 +213,18 @@ namespace Microsoft.Build.BuildEngine {
                                               object o,
                                               string itemName)
                {
-                       BuildItemGroup newItems = ChangeType.ToBuildItemGroup (o, propertyInfo.PropertyType, itemName);
+                       if (o == null)
+                               return;
+
+                       BuildItemGroup newItems;
+                       try {
+                               newItems = ChangeType.ToBuildItemGroup (o, propertyInfo.PropertyType, itemName);
+                       } catch (Exception e) {
+                               throw new Exception (String.Format ("Error publishing Output from task property '{0} {1}' to item named '{2}' : {3}",
+                                                       propertyInfo.PropertyType, propertyInfo.Name, itemName, e.Message),
+                                                       e);
+                       }
+
                        newItems.ParentProject = parentProject;
                        
                        if (parentProject.EvaluatedItemsByName.ContainsKey (itemName)) {
@@ -245,5 +262,3 @@ namespace Microsoft.Build.BuildEngine {
                }
        }
 }
-
-#endif