From 5c11483b8ee7db1c2a8fbb8daae812a3c438d055 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 29 Nov 2016 19:42:27 -0500 Subject: rework uninstaller so it doesn't depend on install package For example, this avoids an issue where the normal SMAPI uninstaller didn't remove files added by the 'SMAPI for developers' installer. --- .../InteractiveInstaller.cs | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/StardewModdingAPI.Installer') diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs index 5be9b14c..1d3802ab 100644 --- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs +++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs @@ -27,6 +27,27 @@ namespace StardewModdingApi.Installer @"C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley" }; + /// The files to remove when uninstalling SMAPI. + private readonly string[] UninstallFiles = + { + // common + "StardewModdingAPI.exe", + "StardewModdingAPI-settings.json", + "StardewModdingAPI.AssemblyRewriters.dll", + "steam_appid.txt", + + // Linux/Mac only + "Mono.Cecil.dll", + "Mono.Cecil.Rocks.dll", + "Newtonsoft.Json.dll", + "StardewModdingAPI", + "StardewModdingAPI.exe.mdb", + "System.Numerics.dll", + + // Windows only + "StardewModdingAPI.pdb" + }; + /********* ** Public methods @@ -47,7 +68,7 @@ namespace StardewModdingApi.Installer /// /// Uninstall logic: /// 1. On Linux/Mac: if a backup of the launcher exists, delete the launcher and restore the backup. - /// 2. Delete all files in the game directory matching a file under package/Windows or package/Mono. + /// 2. Delete all files in the game directory matching one of the . /// public void Run(string[] args) { @@ -127,9 +148,9 @@ namespace StardewModdingApi.Installer // remove SMAPI files this.PrintDebug("Removing SMAPI files..."); - foreach (FileInfo sourceFile in packageDir.EnumerateFiles()) + foreach (string filename in this.UninstallFiles) { - string targetPath = Path.Combine(installDir.FullName, sourceFile.Name); + string targetPath = Path.Combine(installDir.FullName, filename); if (File.Exists(targetPath)) File.Delete(targetPath); } -- cgit