wrong error number
[mono.git] / mcs / tools / gacutil / driver.cs
index 73b9396169735a2f5ec980b3b9f6c05767390f21..bd64ab50ab5641d11e5dc976e9440cfff035a592 100644 (file)
@@ -129,6 +129,7 @@ namespace Mono.Tools {
                                gacdir = GetGacDir ();
                                libdir = GetLibDir ();
                        } else {
+                               gacdir = EnsureLib (gacdir);
                                libdir = Path.Combine (gacdir, "mono");
                                gacdir = Path.Combine (libdir, "gac");
                        }
@@ -221,7 +222,7 @@ namespace Mono.Tools {
                                return false;
                        }
 
-                       string conf_name = name + ".config";
+                       string [] siblings = { ".config", ".mdb" };
                        string version_token = an.Version + "_" +
                                               an.CultureInfo.Name.ToLower (CultureInfo.InvariantCulture) + "_" +
                                               GetStringToken (pub_tok);
@@ -243,8 +244,12 @@ namespace Mono.Tools {
                        }
 
                        File.Copy (name, asmb_path, true);
-                       if (File.Exists (conf_name))
-                               File.Copy (conf_name, asmb_path + ".config", true);
+
+                       foreach (string ext in siblings) {
+                               string sibling = String.Concat (name, ext);
+                               if (File.Exists (sibling))
+                                       File.Copy (sibling, String.Concat (asmb_path, ext), true);
+                       }
 
                        if (package != null) {
                                string link_path = Path.Combine (Path.Combine (link_gacdir, an.Name), version_token);
@@ -259,7 +264,7 @@ namespace Mono.Tools {
                                        WriteLine ("ERROR: Could not create package dir file.");
                                        Environment.Exit (1);
                                }
-                               Symlink (Path.Combine (link_path, asmb_file), ref_path);
+                               Symlink (name, Path.Combine (link_path, asmb_file), ref_path);
 
                                WriteLine ("Package exported to: " + ref_path + " -> " +
                                                Path.Combine (link_path, asmb_file));
@@ -501,7 +506,7 @@ namespace Mono.Tools {
 
                private static bool IsSwitch (string arg)
                {
-                       return (arg [0] == '-' || (arg [0] == '/' && !File.Exists (arg)));
+                       return (arg [0] == '-' || arg [0] == '/');
                }
 
                private static Command GetCommand (string arg)
@@ -549,11 +554,14 @@ namespace Mono.Tools {
                        return c;        
                }
 
-               private static void Symlink (string oldpath, string newpath) {
+               // name = name of dll being installed
+               // oldpath = path the symlink points to -- cannot be assumed to be a valid file
+               // newpath = name of symlink
+               private static void Symlink (string name, string oldpath, string newpath) {
                        if (Path.DirectorySeparatorChar == '/') {
                                symlink (oldpath, newpath);
                        } else {
-                               File.Copy (oldpath, newpath);
+                               File.Copy (name, newpath);
                        }
                }
 
@@ -599,6 +607,14 @@ namespace Mono.Tools {
                        return String.Concat (a, sep, end);
                }
 
+               private static string EnsureLib (string dir)
+               {
+                       DirectoryInfo d = new DirectoryInfo (dir);
+                       if (d.Name == "lib")
+                               return dir;
+                       return Path.Combine (dir, "lib");
+               }
+
                private static void WriteLine ()
                {
                        if (silent)
@@ -708,7 +724,7 @@ namespace Mono.Tools {
 
                        WriteLine ("-gacdir <GACDIR>");
                        WriteLine ("\tUsed to specify the GACs base directory. Once an assembly has been installed\n" +
-                                       "\tto a non standard gacdir the MONO_GAC_PATH environment variable must be used\n" +
+                                       "\tto a non standard gacdir the MONO_GAC_PREFIX environment variable must be used\n" +
                                        "\tto access the assembly.");
                        WriteLine ();