diff --git a/docs/release-notes.md b/docs/release-notes.md
index 0f6fba33..aa9b488c 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -4,7 +4,8 @@
## Upcoming version
* For players:
* You no longer need .NET 5 installed to run SMAPI or the installer.
- * Updated for the Stardew Valley 1.5.5 hotfix on 2021-12-03.
+ * The installer now detects when the game folder contains an incompatible older game version.
+ * Updated for the latest Stardew Valley 1.5.5 hotfix.
* For SMAPI maintainers:
* Added a new [scripted release package process](technical/smapi.md), which removes the need to compile SMAPI on multiple platforms and manually combine them.
diff --git a/src/SMAPI.Installer/Framework/InstallerContext.cs b/src/SMAPI.Installer/Framework/InstallerContext.cs
index 95df32ca..68df2001 100644
--- a/src/SMAPI.Installer/Framework/InstallerContext.cs
+++ b/src/SMAPI.Installer/Framework/InstallerContext.cs
@@ -54,5 +54,12 @@ namespace StardewModdingAPI.Installer.Framework
{
return this.GameScanner.LooksLikeGameFolder(dir);
}
+
+ /// Get whether a folder seems to contain Stardew Valley 1.5.4 or earlier.
+ /// The folder to check.
+ public bool LooksLikeStardewValley154(DirectoryInfo dir)
+ {
+ return this.GameScanner.LooksLikeStardewValley154(dir);
+ }
}
}
diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs
index d8c27a2d..424fe42b 100644
--- a/src/SMAPI.Installer/InteractiveInstaller.cs
+++ b/src/SMAPI.Installer/InteractiveInstaller.cs
@@ -704,7 +704,15 @@ namespace StardewModdingApi.Installer
}
if (!context.LooksLikeGameFolder(directory))
{
- this.PrintWarning("That directory doesn't contain a Stardew Valley executable.");
+ if (context.LooksLikeStardewValley154(directory))
+ {
+ this.PrintWarning("That directory seems to have Stardew Valley 1.5.4 or earlier.");
+ this.PrintWarning("Please update your game to the latest version to use SMAPI.");
+ }
+ else
+ {
+ this.PrintWarning("That directory doesn't contain a Stardew Valley executable.");
+ }
continue;
}
diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
index 7553c07f..c7ebe6e0 100644
--- a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
+++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Xml.Linq;
using System.Xml.XPath;
using StardewModdingAPI.Toolkit.Utilities;
+using System.Reflection;
#if SMAPI_FOR_WINDOWS
using Microsoft.Win32;
#endif
@@ -59,6 +60,32 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning
&& dir.EnumerateFiles("Stardew Valley.dll").Any();
}
+ /// Get whether a folder seems to contain Stardew Valley 1.5.4 or earlier.
+ /// The folder to check.
+ public bool LooksLikeStardewValley154(DirectoryInfo dir)
+ {
+ if (!dir.Exists || this.LooksLikeGameFolder(dir))
+ return false;
+
+ // get legacy executable
+ FileInfo executable = new FileInfo(Path.Combine(dir.FullName, "Stardew Valley.exe"));
+ if (!executable.Exists)
+ executable = new FileInfo(Path.Combine(dir.FullName, "StardewValley.exe"));
+ if (!executable.Exists)
+ return false;
+
+ // check if it's a standard .NET assembly
+ // This will fail in Stardew Valley 1.5.5+, where it's a binary wrapper around Stardew Valley.dll.
+ try
+ {
+ Version version = AssemblyName.GetAssemblyName(executable.FullName).Version;
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
/*********
** Private methods