Fix bug #484773.
authorAnkit Jain <radical@corewars.org>
Thu, 19 Mar 2009 00:58:12 +0000 (00:58 -0000)
committerAnkit Jain <radical@corewars.org>
Thu, 19 Mar 2009 00:58:12 +0000 (00:58 -0000)
* Main.cs (Execute): Check whether the project file exists or not.
* Parameters.cs (ParseArguments): Handle absolute paths too.

svn path=/trunk/mcs/; revision=129759

mcs/tools/xbuild/ChangeLog
mcs/tools/xbuild/Main.cs
mcs/tools/xbuild/Parameters.cs

index 01ef0e975d989e2bc1f04781b2e01bbba6f9066a..c516c95e7e0c7b75c2d78f59c7f71d6fb9550732 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-19  Ankit Jain  <jankit@novell.com>
+
+       Fix bug #484773.
+       * Main.cs (Execute): Check whether the project file exists or not.
+       * Parameters.cs (ParseArguments): Handle absolute paths too.
+
 2009-03-13  Ankit Jain  <jankit@novell.com>
 
        * Main.cs (Execute): Build the project/sln with current directory set to
index 69ceec27ace12b56841a6fc67fb554bf55e99b99..dea952d5c3294702066ce10891dc2209374c2bed 100644 (file)
@@ -103,13 +103,20 @@ namespace Mono.XBuild.CommandLine {
                                }
 
                                string projectFile = parameters.ProjectFile;
+                               if (!File.Exists (projectFile)) {
+                                       ErrorUtilities.ReportError (0, String.Format ("Project file '{0}' not found.", projectFile));
+                                       return;
+                               }
+
                                if (projectFile.EndsWith (".sln"))
                                        projectFile = GenerateSolutionProject (projectFile);
 
                                project.Load (projectFile);
                                
                                string oldCurrentDirectory = Environment.CurrentDirectory;
-                               Directory.SetCurrentDirectory (Path.GetDirectoryName (projectFile));
+                               string dir = Path.GetDirectoryName (projectFile);
+                               if (!String.IsNullOrEmpty (dir))
+                                       Directory.SetCurrentDirectory (dir);
                                result = engine.BuildProject (project, parameters.Targets, null);
                                Directory.SetCurrentDirectory (oldCurrentDirectory);
                        }
index 86b5ba77e2a63befffb60148740c6af925190a34..a33a85211fbb80c9cf68d2cd66bc1d269874864d 100644 (file)
@@ -97,9 +97,7 @@ namespace Mono.XBuild.CommandLine {
                                LoadResponseFile (responseFile);
                        }
                        foreach (string s in flatArguments) {
-                               if (s [0] == '/') {
-                                       ParseFlatArgument (s);
-                               } else
+                               if (s [0] != '/' || !ParseFlatArgument (s))
                                        remainingArguments.Add (s);
                        }
                        if (remainingArguments.Count == 0) {
@@ -165,7 +163,7 @@ namespace Mono.XBuild.CommandLine {
                         }
                }
                
-               private void ParseFlatArgument (string s)
+               private bool ParseFlatArgument (string s)
                {
                        switch (s) {
                        case "/help":
@@ -191,24 +189,22 @@ namespace Mono.XBuild.CommandLine {
                        default:
                                if (s.StartsWith ("/target:") || s.StartsWith ("/t:")) {
                                        ProcessTarget (s);
-                               }
-                               if (s.StartsWith ("/property:") || s.StartsWith ("/p:")) {
+                               } else if (s.StartsWith ("/property:") || s.StartsWith ("/p:")) {
                                        ProcessProperty (s);
-                               }
-                               if (s.StartsWith ("/logger:") || s.StartsWith ("/l:")) {
+                               } else  if (s.StartsWith ("/logger:") || s.StartsWith ("/l:")) {
                                        ProcessLogger (s);
-                               }
-                               if (s.StartsWith ("/verbosity:") || s.StartsWith ("/v:")) {
+                               } else if (s.StartsWith ("/verbosity:") || s.StartsWith ("/v:")) {
                                        ProcessVerbosity (s);
-                               }
-                               if (s.StartsWith ("/consoleloggerparameters:") || s.StartsWith ("/clp:")) {
+                               } else if (s.StartsWith ("/consoleloggerparameters:") || s.StartsWith ("/clp:")) {
                                        ProcessConsoleLoggerParameters (s);
-                               }
-                               if (s.StartsWith ("/validate:") || s.StartsWith ("/val:")) {
+                               } else if (s.StartsWith ("/validate:") || s.StartsWith ("/val:")) {
                                        ProcessValidate (s);
-                               }
+                               } else
+                                       return false;
                                break;
                        }
+
+                       return true;
                }
                
                internal void ProcessTarget (string s)