diff --git a/CKAN/CmdLine/Action/Upgrade.cs b/CKAN/CmdLine/Action/Upgrade.cs index 1882538f8d..843fbcd69d 100644 --- a/CKAN/CmdLine/Action/Upgrade.cs +++ b/CKAN/CmdLine/Action/Upgrade.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; namespace CKAN.CmdLine @@ -60,6 +61,14 @@ public int RunCommand(CKAN.KSP ksp, object raw_options) } + var auto_detected_modules = to_upgrade.Where(module => ksp.Registry.IsAutodetected(module.identifier)).ToList(); + foreach (var module in auto_detected_modules.Select(mod => mod.identifier)) + { + User.RaiseMessage("Cannot upgrade {0} as it was not installed by CKAN. \n Please remove manually before trying again", module); + } + //Exit if any are auto_detected + if (auto_detected_modules.Any()) return Exit.ERROR; + User.RaiseMessage("\nUpgrading modules...\n"); // TODO: These instances all need to go. ModuleInstaller.GetInstance(ksp, User).Upgrade(to_upgrade,new NetAsyncDownloader(User)); diff --git a/CKAN/CmdLine/Main.cs b/CKAN/CmdLine/Main.cs index 55331e6b9e..630aa3722d 100644 --- a/CKAN/CmdLine/Main.cs +++ b/CKAN/CmdLine/Main.cs @@ -155,6 +155,7 @@ public static int Main(string[] args) return Available(manager.CurrentInstance, user); case "install": + Scan(manager.CurrentInstance); return Install((InstallOptions)cmdline.options, manager.CurrentInstance, user); case "scan": @@ -170,6 +171,7 @@ public static int Main(string[] args) return Remove((RemoveOptions)cmdline.options, manager.CurrentInstance, user); case "upgrade": + Scan(manager.CurrentInstance); var upgrade = new Upgrade(user); return upgrade.RunCommand(manager.CurrentInstance, cmdline.options); diff --git a/CKAN/GUI/Util.cs b/CKAN/GUI/Util.cs index fa6a92c204..4b6108c5e7 100644 --- a/CKAN/GUI/Util.cs +++ b/CKAN/GUI/Util.cs @@ -1,13 +1,14 @@ using System; -using System.Runtime.InteropServices; -using System.Windows.Forms; + namespace CKAN { + using System.Runtime.InteropServices; + using System.Windows.Forms; public static class Util { - + public static bool IsLinux { get @@ -75,12 +76,17 @@ public static void HideConsoleWindow() ShowWindow(GetConsoleWindow(), 0); } } + } +} - +namespace CKAN +{ + public static class UtilWithoutWinForm + { public static bool IsInstallable(this GUIMod mod) { + return !(mod == null || mod.IsAutodetected || mod.IsIncompatible); } - } - + } }