From 2b9703f98fedcf97fd5e511f1e30bcc8fd94b5cc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 11 May 2020 01:40:46 -0400 Subject: fix Harmony issue when assembly is loaded from memory (#711) --- src/SMAPI.Installer/InteractiveInstaller.cs | 40 ++--------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 5b0c6e1f..1457848b 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Threading; using Microsoft.Win32; using StardewModdingApi.Installer.Enums; using StardewModdingAPI.Installer.Framework; @@ -624,7 +623,7 @@ namespace StardewModdingApi.Installer { try { - this.ForceDelete(Directory.Exists(path) ? new DirectoryInfo(path) : (FileSystemInfo)new FileInfo(path)); + FileUtilities.ForceDelete(Directory.Exists(path) ? new DirectoryInfo(path) : (FileSystemInfo)new FileInfo(path)); break; } catch (Exception ex) @@ -665,41 +664,6 @@ namespace StardewModdingApi.Installer } } - /// Delete a file or folder regardless of file permissions, and block until deletion completes. - /// The file or folder to reset. - /// This method is mirrored from FileUtilities.ForceDelete in the toolkit. - private void ForceDelete(FileSystemInfo entry) - { - // ignore if already deleted - entry.Refresh(); - if (!entry.Exists) - return; - - // delete children - if (entry is DirectoryInfo folder) - { - foreach (FileSystemInfo child in folder.GetFileSystemInfos()) - this.ForceDelete(child); - } - - // reset permissions & delete - entry.Attributes = FileAttributes.Normal; - entry.Delete(); - - // wait for deletion to finish - for (int i = 0; i < 10; i++) - { - entry.Refresh(); - if (entry.Exists) - Thread.Sleep(500); - } - - // throw exception if deletion didn't happen before timeout - entry.Refresh(); - if (entry.Exists) - throw new IOException($"Timed out trying to delete {entry.FullName}"); - } - /// Interactively ask the user to choose a value. /// A callback which prints a message to the console. /// The message to print. @@ -707,7 +671,7 @@ namespace StardewModdingApi.Installer /// The indentation to prefix to output. private string InteractivelyChoose(string message, string[] options, string indent = "", Action print = null) { - print = print ?? this.PrintInfo; + print ??= this.PrintInfo; while (true) { -- cgit From 79181012ee01e93c1af7c4bf8bd1a3a717274ded Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 14 Jun 2020 10:55:52 -0400 Subject: tweak build files --- build/common.targets | 1 + src/SMAPI.Installer/SMAPI.Installer.csproj | 8 +-- .../SMAPI.ModBuildConfig.Analyzer.csproj | 4 -- .../SMAPI.ModBuildConfig.csproj | 25 ++----- src/SMAPI.ModBuildConfig/build/smapi.targets | 56 ++++----------- .../SMAPI.Mods.ConsoleCommands.csproj | 47 +++---------- .../SMAPI.Mods.SaveBackup.csproj | 16 +---- .../SMAPI.Toolkit.CoreInterfaces.csproj | 6 +- src/SMAPI.Toolkit/ModToolkit.cs | 3 - src/SMAPI.Toolkit/Properties/AssemblyInfo.cs | 4 ++ src/SMAPI.Toolkit/SMAPI.Toolkit.csproj | 7 +- src/SMAPI/SMAPI.csproj | 81 +++++----------------- 12 files changed, 56 insertions(+), 202 deletions(-) create mode 100644 src/SMAPI.Toolkit/Properties/AssemblyInfo.cs (limited to 'src/SMAPI.Installer') diff --git a/build/common.targets b/build/common.targets index 41bea8af..ddfbd71a 100644 --- a/build/common.targets +++ b/build/common.targets @@ -7,6 +7,7 @@ 3.5.0 SMAPI + latest $(AssemblySearchPaths);{GAC} $(DefineConstants);SMAPI_FOR_WINDOWS diff --git a/src/SMAPI.Installer/SMAPI.Installer.csproj b/src/SMAPI.Installer/SMAPI.Installer.csproj index 79e19d89..44ed3bd1 100644 --- a/src/SMAPI.Installer/SMAPI.Installer.csproj +++ b/src/SMAPI.Installer/SMAPI.Installer.csproj @@ -1,11 +1,8 @@  - - SMAPI.Installer StardewModdingAPI.Installer The SMAPI installer for players. net45 - latest Exe x86 false @@ -16,13 +13,10 @@ - - PreserveNewest - + - diff --git a/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj b/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj index 3659e25a..0d109b83 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj +++ b/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj @@ -1,11 +1,8 @@  - - SMAPI.ModBuildConfig.Analyzer StardewModdingAPI.ModBuildConfig.Analyzer 3.0.0 netstandard2.0 - latest false bin latest @@ -19,5 +16,4 @@ - diff --git a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj index ccbd9a85..5061b01b 100644 --- a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj @@ -1,24 +1,12 @@  - - SMAPI.ModBuildConfig StardewModdingAPI.ModBuildConfig - 3.0.0 + 3.1.0 net45 - latest x86 false - - - - - - - - - @@ -28,19 +16,16 @@ - - mod-package.md - + - - PreserveNewest - + + + - diff --git a/src/SMAPI.ModBuildConfig/build/smapi.targets b/src/SMAPI.ModBuildConfig/build/smapi.targets index 5ca9f032..bfee3b33 100644 --- a/src/SMAPI.ModBuildConfig/build/smapi.targets +++ b/src/SMAPI.ModBuildConfig/build/smapi.targets @@ -38,58 +38,26 @@ **********************************************--> - - $(GamePath)\$(GameExecutableName).exe - $(CopyModReferencesToBuildOutput) - - - $(GamePath)\StardewValley.GameData.dll - $(CopyModReferencesToBuildOutput) - - - $(GamePath)\StardewModdingAPI.exe - $(CopyModReferencesToBuildOutput) - - - $(GamePath)\smapi-internal\SMAPI.Toolkit.CoreInterfaces.dll - $(CopyModReferencesToBuildOutput) - - - $(GamePath)\xTile.dll - $(CopyModReferencesToBuildOutput) - - - $(GamePath)\smapi-internal\0Harmony.dll - $(CopyModReferencesToBuildOutput) - + + + + + + - - $(CopyModReferencesToBuildOutput) - - - $(CopyModReferencesToBuildOutput) - - - $(CopyModReferencesToBuildOutput) - - - $(CopyModReferencesToBuildOutput) - - - $(GamePath)\Netcode.dll - $(CopyModReferencesToBuildOutput) - + + + + + - - $(GamePath)\MonoGame.Framework.dll - $(CopyModReferencesToBuildOutput) - + diff --git a/src/SMAPI.Mods.ConsoleCommands/SMAPI.Mods.ConsoleCommands.csproj b/src/SMAPI.Mods.ConsoleCommands/SMAPI.Mods.ConsoleCommands.csproj index 526d406b..1e3208de 100644 --- a/src/SMAPI.Mods.ConsoleCommands/SMAPI.Mods.ConsoleCommands.csproj +++ b/src/SMAPI.Mods.ConsoleCommands/SMAPI.Mods.ConsoleCommands.csproj @@ -1,72 +1,45 @@  - ConsoleCommands StardewModdingAPI.Mods.ConsoleCommands net45 - latest false x86 - - False - + - - $(GamePath)\$(GameExecutableName).exe - False - - - $(GamePath)\StardewValley.GameData.dll - False - + + - - $(GamePath)\Netcode.dll - False - - - False - - - False - - - False - - - False - + + + + + - - $(GamePath)\MonoGame.Framework.dll - False - + - - PreserveNewest - + - diff --git a/src/SMAPI.Mods.SaveBackup/SMAPI.Mods.SaveBackup.csproj b/src/SMAPI.Mods.SaveBackup/SMAPI.Mods.SaveBackup.csproj index 970ccea8..98a3f0cc 100644 --- a/src/SMAPI.Mods.SaveBackup/SMAPI.Mods.SaveBackup.csproj +++ b/src/SMAPI.Mods.SaveBackup/SMAPI.Mods.SaveBackup.csproj @@ -1,34 +1,24 @@  - SaveBackup StardewModdingAPI.Mods.SaveBackup net45 - latest false x86 - - False - + - - $(GamePath)\$(GameExecutableName).exe - False - + - - PreserveNewest - + - diff --git a/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj b/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj index accc9175..2bddc46a 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj +++ b/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj @@ -1,15 +1,11 @@  - - SMAPI.Toolkit.CoreInterfaces StardewModdingAPI Provides toolkit interfaces which are available to SMAPI mods. net4.5;netstandard2.0 - latest - bin\$(Configuration)\$(TargetFramework)\SMAPI.Toolkit.CoreInterfaces.xml + true x86 - diff --git a/src/SMAPI.Toolkit/ModToolkit.cs b/src/SMAPI.Toolkit/ModToolkit.cs index 80b14659..08fe0fed 100644 --- a/src/SMAPI.Toolkit/ModToolkit.cs +++ b/src/SMAPI.Toolkit/ModToolkit.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.CompilerServices; using System.Threading.Tasks; using Newtonsoft.Json; using StardewModdingAPI.Toolkit.Framework.Clients.Wiki; @@ -11,8 +10,6 @@ using StardewModdingAPI.Toolkit.Framework.ModData; using StardewModdingAPI.Toolkit.Framework.ModScanning; using StardewModdingAPI.Toolkit.Serialization; -[assembly: InternalsVisibleTo("StardewModdingAPI")] -[assembly: InternalsVisibleTo("SMAPI.Web")] namespace StardewModdingAPI.Toolkit { /// A convenience wrapper for the various tools. diff --git a/src/SMAPI.Toolkit/Properties/AssemblyInfo.cs b/src/SMAPI.Toolkit/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..233e680b --- /dev/null +++ b/src/SMAPI.Toolkit/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("StardewModdingAPI")] +[assembly: InternalsVisibleTo("SMAPI.Web")] diff --git a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj index 4e6918ad..71ea0f12 100644 --- a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj +++ b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj @@ -1,14 +1,10 @@  - - SMAPI.Toolkit StardewModdingAPI.Toolkit A library which encapsulates mod-handling logic for mod managers and tools. Not intended for use by mods. net4.5;netstandard2.0 - latest - bin\$(Configuration)\$(TargetFramework)\SMAPI.Toolkit.xml + true x86 - StardewModdingAPI.Toolkit @@ -24,5 +20,4 @@ - diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj index d36d7b4c..02f1763f 100644 --- a/src/SMAPI/SMAPI.csproj +++ b/src/SMAPI/SMAPI.csproj @@ -1,14 +1,12 @@  - StardewModdingAPI StardewModdingAPI The modding API for Stardew Valley. net45 - latest x86 Exe - bin\$(Configuration)\StardewModdingAPI.xml + true false true icon.ico @@ -23,54 +21,24 @@ - - $(GamePath)\$(GameExecutableName).exe - False - - - $(GamePath)\StardewValley.GameData.dll - False - - - True - - - True - - - $(GamePath)\GalaxyCSharp.dll - False - - - $(GamePath)\Lidgren.Network.dll - False - - - $(GamePath)\xTile.dll - False - + + + + + + + - - $(GamePath)\Netcode.dll - False - - - False - - - False - - - False - - - False - + + + + + @@ -78,10 +46,7 @@ - - $(GamePath)\MonoGame.Framework.dll - False - + @@ -92,22 +57,12 @@ - - PreserveNewest - - - SMAPI.metadata.json - PreserveNewest - - - PreserveNewest - - - PreserveNewest - + + + + - -- cgit