summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-03-16 17:06:53 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-03-16 17:06:53 -0400
commitabfa2022aad8478c369158e89a38eaae9bd81c96 (patch)
tree9f8b760320942b0aef0cb210cd2e8e38284869ba /src
parent3d4c603bd387d462904d302377db63d7cd917916 (diff)
downloadSMAPI-abfa2022aad8478c369158e89a38eaae9bd81c96.tar.gz
SMAPI-abfa2022aad8478c369158e89a38eaae9bd81c96.tar.bz2
SMAPI-abfa2022aad8478c369158e89a38eaae9bd81c96.zip
validate XNA 4.0+ is installed on Windows in SMAPI installer
Diffstat (limited to 'src')
-rw-r--r--src/StardewModdingAPI.Installer/InteractiveInstaller.cs46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
index 52d0642a..0e920f1f 100644
--- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
+++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
@@ -157,17 +157,27 @@ namespace StardewModdingApi.Installer
}
/****
- ** validate .NET Framework version
+ ** validate Windows dependencies
****/
- if (platform == Platform.Windows && !this.HasNetFramework45(platform))
+ if (platform == Platform.Windows)
{
- this.PrintError(Environment.OSVersion.Version >= this.Windows7Version
- ? "Please install the latest version of .NET Framework before installing SMAPI." // Windows 7+
- : "Please install .NET Framework 4.5 before installing SMAPI." // Windows Vista or earlier
- );
- this.PrintError("See the download page at https://www.microsoft.com/net/download/framework for details.");
- Console.ReadLine();
- return;
+ // .NET Framework 4.5+
+ if (!this.HasNetFramework45(platform))
+ {
+ this.PrintError(Environment.OSVersion.Version >= this.Windows7Version
+ ? "Please install the latest version of .NET Framework before installing SMAPI." // Windows 7+
+ : "Please install .NET Framework 4.5 before installing SMAPI." // Windows Vista or earlier
+ );
+ this.PrintError("See the download page at https://www.microsoft.com/net/download/framework for details.");
+ Console.ReadLine();
+ return;
+ }
+ if (!this.HasXNA(platform))
+ {
+ this.PrintError("You don't seem to have XNA Framework installed. Please run the game at least once before installing SMAPI, so it can perform its first-time setup.");
+ Console.ReadLine();
+ return;
+ }
}
Console.WriteLine();
@@ -378,7 +388,7 @@ namespace StardewModdingApi.Installer
Console.WriteLine(text);
}
- /// <summary>Get whether the current system has .NET Framework 4.5 or later installed.</summary>
+ /// <summary>Get whether the current system has .NET Framework 4.5 or later installed. This only applies on Windows.</summary>
/// <param name="platform">The current platform.</param>
/// <exception cref="NotSupportedException">The current platform is not Windows.</exception>
private bool HasNetFramework45(Platform platform)
@@ -394,6 +404,22 @@ namespace StardewModdingApi.Installer
}
}
+ /// <summary>Get whether the current system has XNA Framework installed. This only applies on Windows.</summary>
+ /// <param name="platform">The current platform.</param>
+ /// <exception cref="NotSupportedException">The current platform is not Windows.</exception>
+ private bool HasXNA(Platform platform)
+ {
+ switch (platform)
+ {
+ case Platform.Windows:
+ using (RegistryKey key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(@"SOFTWARE\Microsoft\XNA\Framework"))
+ return key != null; // XNA Framework 4.0+
+
+ default:
+ throw new NotSupportedException("The installed XNA Framework version can only be checked on Windows.");
+ }
+ }
+
/// <summary>Interactively delete a file or folder path, and block until deletion completes.</summary>
/// <param name="path">The file or folder path.</param>
private void InteractivelyDelete(string path)