summaryrefslogtreecommitdiff
path: root/src/SMAPI/Program.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-08-19 00:40:12 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-11-28 00:01:46 -0500
commit294f2a311ea2cfb590529522c0afae8e5a4f44fd (patch)
treed3e9b0f32a0a6cbd35e7838b7a234ff7d60354b2 /src/SMAPI/Program.cs
parent89c98223ebf6bfeee5ef587ab748995e09dd4310 (diff)
downloadSMAPI-294f2a311ea2cfb590529522c0afae8e5a4f44fd.tar.gz
SMAPI-294f2a311ea2cfb590529522c0afae8e5a4f44fd.tar.bz2
SMAPI-294f2a311ea2cfb590529522c0afae8e5a4f44fd.zip
fix error resolving native DLLs like libSkiaSharp
Diffstat (limited to 'src/SMAPI/Program.cs')
-rw-r--r--src/SMAPI/Program.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index 0417697b..67ff8322 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -5,6 +5,7 @@ using System.Reflection;
using System.Threading;
using StardewModdingAPI.Framework;
using StardewModdingAPI.Toolkit.Serialization.Models;
+using StardewModdingAPI.Toolkit.Utilities;
namespace StardewModdingAPI
{
@@ -33,6 +34,7 @@ namespace StardewModdingAPI
Program.AssertGamePresent();
Program.AssertGameVersion();
Program.AssertSmapiVersions();
+ Program.AssertDepsJson();
Program.Start(args);
}
catch (BadImageFormatException ex) when (ex.FileName == EarlyConstants.GameAssemblyName)
@@ -130,6 +132,20 @@ namespace StardewModdingAPI
}
}
+ /// <summary>Assert that SMAPI's <c>StardewModdingAPI.deps.json</c> matches <c>Stardew Valley.deps.json</c>, fixing it if necessary.</summary>
+ /// <remarks>This is needed to resolve native DLLs like libSkiaSharp.</remarks>
+ private static void AssertDepsJson()
+ {
+ string sourcePath = Path.Combine(Constants.ExecutionPath, "Stardew Valley.deps.json");
+ string targetPath = Path.Combine(Constants.ExecutionPath, "StardewModdingAPI.deps.json");
+
+ if (!File.Exists(targetPath) || FileUtilities.GetFileHash(sourcePath) != FileUtilities.GetFileHash(targetPath))
+ {
+ File.Copy(sourcePath, targetPath, overwrite: true);
+ Program.PrintErrorAndExit($"The '{Path.GetFileName(targetPath)}' file didn't match the game's version. SMAPI fixed it automatically, but you must restart SMAPI for the change to take effect.");
+ }
+ }
+
/// <summary>Initialize SMAPI and launch the game.</summary>
/// <param name="args">The command-line arguments.</param>
/// <remarks>This method is separate from <see cref="Main"/> because that can't contain any references to assemblies loaded by <see cref="CurrentDomain_AssemblyResolve"/> (e.g. via <see cref="Constants"/>), or Mono will incorrectly show an assembly resolution error before assembly resolution is set up.</remarks>