Merge pull request #485 from mtausig/master
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / Project.cs
index d2f466121212990779e30341db5ba6941c510b23..ac6b72dfcae424b8d3725e18330fb92e09a884ab 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;
 using System.Collections.Generic;
@@ -297,6 +295,13 @@ namespace Microsoft.Build.BuildEngine {
                                        Directory.SetCurrentDirectory (Path.GetDirectoryName (fullFileName));
                                building = true;
                                result = BuildInternal (targetNames, targetOutputs, buildFlags);
+                       } catch (InvalidProjectFileException ie) {
+                               ParentEngine.LogErrorWithFilename (fullFileName, ie.Message);
+                               ParentEngine.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", fullFileName, ie.ToString ()));
+                       } catch (Exception e) {
+                               ParentEngine.LogErrorWithFilename (fullFileName, e.Message);
+                               ParentEngine.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", fullFileName, e.ToString ()));
+                               throw;
                        } finally {
                                ParentEngine.EndProjectBuild (this, result);
                                current_settings = BuildSettings.None;
@@ -344,9 +349,13 @@ namespace Microsoft.Build.BuildEngine {
                                initialTargetsBuilt = true;
                        }
 
-                       foreach (string target in targetNames)
+                       foreach (string target in targetNames) {
+                               if (target == null)
+                                       throw new ArgumentNullException ("Target name cannot be null");
+
                                if (!BuildTarget (target.Trim (), targetOutputs))
                                        return false;
+                       }
                                
                        return true;
                }
@@ -946,8 +955,8 @@ namespace Microsoft.Build.BuildEngine {
                {
                        evaluatedItems = new BuildItemGroup (null, this, null, true);
                        evaluatedItemsIgnoringCondition = new BuildItemGroup (null, this, null, true);
-                       evaluatedItemsByName = new Dictionary <string, BuildItemGroup> (StringComparer.InvariantCultureIgnoreCase);
-                       evaluatedItemsByNameIgnoringCondition = new Dictionary <string, BuildItemGroup> (StringComparer.InvariantCultureIgnoreCase);
+                       evaluatedItemsByName = new Dictionary <string, BuildItemGroup> (StringComparer.OrdinalIgnoreCase);
+                       evaluatedItemsByNameIgnoringCondition = new Dictionary <string, BuildItemGroup> (StringComparer.OrdinalIgnoreCase);
                        if (building && current_settings == BuildSettings.None)
                                RemoveBuiltTargets ();
 
@@ -1134,7 +1143,7 @@ namespace Microsoft.Build.BuildEngine {
                                                "the first import of this file will be used, ignoring others.",
                                                import.EvaluatedProjectPath, existingImport.ContainedInProjectFileName);
 
-                               return false;
+                               return true;
                        }
 
                        if (String.Compare (fullFileName, import.EvaluatedProjectPath) == 0) {
@@ -1142,9 +1151,13 @@ namespace Microsoft.Build.BuildEngine {
                                                "The main project file was imported here, which creates a circular " +
                                                "reference. Ignoring this import.");
 
-                               return false;
+                               return true;
                        }
 
+                       if (project_load_settings != ProjectLoadSettings.IgnoreMissingImports &&
+                           !import.CheckEvaluatedProjectPathExists ())
+                               return false;
+
                        Imports.Add (import);
                        string importingFile = importingProject != null ? importingProject.FullFileName : FullFileName;
                        ParentEngine.LogMessage (MessageImportance.Low,
@@ -1594,5 +1607,3 @@ namespace Microsoft.Build.BuildEngine {
 
        }
 }
-
-#endif