summaryrefslogtreecommitdiff
path: root/src/SMAPI/Program.cs
diff options
context:
space:
mode:
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>