From 4af0786ecb6b16826b2a23b1448c3ab8f5ccd569 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 30 Aug 2018 18:14:40 -0400 Subject: fix assembly load security exceptions by restructuring installer and adding *.exe.config files (#582, #588) --- src/SMAPI.Installer/InteractiveInstaller.cs | 2 +- src/SMAPI.Installer/Program.cs | 8 +------- src/SMAPI.Installer/StardewModdingAPI.Installer.csproj | 8 +++++++- src/SMAPI.Installer/windows-exe-config.xml | 5 +++++ src/SMAPI.Installer/windows-install.bat | 1 + 5 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 src/SMAPI.Installer/windows-exe-config.xml create mode 100644 src/SMAPI.Installer/windows-install.bat (limited to 'src') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index e6e71cf4..1da5c35a 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -440,7 +440,7 @@ namespace StardewModdingApi.Installer this.PrintDebug("Adding SMAPI files..."); foreach (FileSystemInfo sourceEntry in paths.PackageDir.EnumerateFileSystemInfos().Where(this.ShouldCopy)) { - if (sourceEntry.Name == this.InstallerFileName) + if (sourceEntry.Name.StartsWith(this.InstallerFileName)) // e.g. install.exe or install.exe.config continue; this.InteractivelyDelete(Path.Combine(paths.GameDir.FullName, sourceEntry.Name)); diff --git a/src/SMAPI.Installer/Program.cs b/src/SMAPI.Installer/Program.cs index 375678d2..ad5cf47f 100644 --- a/src/SMAPI.Installer/Program.cs +++ b/src/SMAPI.Installer/Program.cs @@ -2,7 +2,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; -using StardewModdingAPI.Internal; namespace StardewModdingApi.Installer { @@ -14,8 +13,7 @@ namespace StardewModdingApi.Installer *********/ /// The absolute path to search for referenced assemblies. [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute", Justification = "The assembly location is never null in this context.")] - private static string DllSearchPath; - + private static readonly string DllSearchPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "smapi-internal"); /********* ** Public methods @@ -25,10 +23,6 @@ namespace StardewModdingApi.Installer public static void Main(string[] args) { // set up assembly resolution - string installerPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - Program.DllSearchPath = EnvironmentUtility.DetectPlatform() == Platform.Windows - ? Path.Combine(installerPath, "internal", "Windows", "smapi-internal") - : Path.Combine(installerPath, "smapi-internal"); AppDomain.CurrentDomain.AssemblyResolve += Program.CurrentDomain_AssemblyResolve; // launch installer diff --git a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj index e9af16c5..22c55af7 100644 --- a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj +++ b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj @@ -46,11 +46,17 @@ - + Always + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SMAPI.Installer/windows-exe-config.xml b/src/SMAPI.Installer/windows-exe-config.xml new file mode 100644 index 00000000..386c7f1a --- /dev/null +++ b/src/SMAPI.Installer/windows-exe-config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/SMAPI.Installer/windows-install.bat b/src/SMAPI.Installer/windows-install.bat new file mode 100644 index 00000000..716c7789 --- /dev/null +++ b/src/SMAPI.Installer/windows-install.bat @@ -0,0 +1 @@ +START /WAIT /B internal/Windows/install.exe -- cgit