[xbuild] Handle unknown exceptions.
authorAnkit Jain <radical@corewars.org>
Fri, 11 Mar 2011 13:05:19 +0000 (18:35 +0530)
committerAnkit Jain <radical@corewars.org>
Fri, 11 Mar 2011 13:16:19 +0000 (18:46 +0530)
Re-throw any unknown exceptions.
* Project.cs: Log the exception, doing it here also, so that direct
project.Build(..) call failures also get logged.
* Engine.cs: Log the unknown exception only if the build is running.
This allows for the case when Project.Build caught it and ended the
build.

mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs

index 47b5ffddffd0e5213883adcdeb7ff3040db9727c..7d5db3f64b3ce8d3801e7bca20ba9bb6b7ffbc98 100644 (file)
@@ -239,9 +239,11 @@ namespace Microsoft.Build.BuildEngine {
                                this.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", projectFile, ie.ToString ()));
                                return false;
                        } catch (Exception e) {
-                               this.LogErrorWithFilename (projectFile, e.Message);
-                               this.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", projectFile, e.ToString ()));
-                               return false;
+                               if (buildStarted) {
+                                       this.LogErrorWithFilename (projectFile, e.Message);
+                                       this.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", projectFile, e.ToString ()));
+                               }
+                               throw;
                        } finally {
                                EndEngineBuild (result);
                        }
index d2f466121212990779e30341db5ba6941c510b23..6e7971deb7a180d7e4efa22094243bc87f8cd9b2 100644 (file)
@@ -297,6 +297,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;