summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Installer
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI.Installer')
-rw-r--r--src/StardewModdingAPI.Installer/InteractiveInstaller.cs58
-rw-r--r--src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj44
-rw-r--r--src/StardewModdingAPI.Installer/readme.txt27
3 files changed, 57 insertions, 72 deletions
diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
index ef813eb3..5abcfc8f 100644
--- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
+++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
@@ -27,6 +27,7 @@ namespace StardewModdingApi.Installer
yield return $"{Environment.GetEnvironmentVariable("HOME")}/.local/share/Steam/steamapps/common/Stardew Valley";
// Mac
+ yield return "/Applications/Stardew Valley.app/Contents/MacOS";
yield return $"{Environment.GetEnvironmentVariable("HOME")}/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS";
// Windows
@@ -50,32 +51,38 @@ namespace StardewModdingApi.Installer
}
}
- /// <summary>The directory or file paths to remove when uninstalling SMAPI, relative to the game directory.</summary>
- private readonly string[] UninstallPaths =
+ /// <summary>Get the absolute file or folder paths to remove when uninstalling SMAPI.</summary>
+ /// <param name="installDir">The folder for Stardew Valley and SMAPI.</param>
+ /// <param name="modsDir">The folder for SMAPI mods.</param>
+ private IEnumerable<string> GetUninstallPaths(DirectoryInfo installDir, DirectoryInfo modsDir)
{
+ Func<string, string> installPath = path => Path.Combine(installDir.FullName, path);
+
// common
- "StardewModdingAPI.exe",
- "StardewModdingAPI.config.json",
- "StardewModdingAPI.data.json",
- "StardewModdingAPI.AssemblyRewriters.dll",
- "steam_appid.txt",
+ yield return installPath("StardewModdingAPI.exe");
+ yield return installPath("StardewModdingAPI.config.json");
+ yield return installPath("StardewModdingAPI.data.json");
+ yield return installPath("StardewModdingAPI.AssemblyRewriters.dll");
+ yield return installPath("steam_appid.txt");
// Linux/Mac only
- "Mono.Cecil.dll",
- "Mono.Cecil.Rocks.dll",
- "Newtonsoft.Json.dll",
- "StardewModdingAPI",
- "StardewModdingAPI.exe.mdb",
- "System.Numerics.dll",
- "System.Runtime.Caching.dll",
+ yield return installPath("Mono.Cecil.dll");
+ yield return installPath("Mono.Cecil.Rocks.dll");
+ yield return installPath("Newtonsoft.Json.dll");
+ yield return installPath("StardewModdingAPI");
+ yield return installPath("StardewModdingAPI.exe.mdb");
+ yield return installPath("System.Numerics.dll");
+ yield return installPath("System.Runtime.Caching.dll");
// Windows only
- "StardewModdingAPI.pdb",
+ yield return installPath("StardewModdingAPI.pdb");
// obsolete
- "Mods/.cache", // 1.3-1.4
- "StardewModdingAPI-settings.json" // 1.0-1.4
- };
+ yield return installPath("Mods/.cache"); // 1.3-1.4
+ yield return installPath("StardewModdingAPI-settings.json"); // 1.0-1.4
+ foreach (DirectoryInfo modDir in modsDir.EnumerateDirectories())
+ yield return Path.Combine(modDir.FullName, ".cache"); // 1.4–1.7
+ }
/// <summary>Whether the current console supports color formatting.</summary>
private static readonly bool ConsoleSupportsColor = InteractiveInstaller.GetConsoleSupportsColor();
@@ -109,8 +116,9 @@ namespace StardewModdingApi.Installer
** collect details
****/
Platform platform = this.DetectPlatform();
- DirectoryInfo packageDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), platform.ToString()));
+ DirectoryInfo packageDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "internal", platform.ToString()));
DirectoryInfo installDir = this.InteractivelyGetInstallPath(platform);
+ DirectoryInfo modsDir = new DirectoryInfo(Path.Combine(installDir.FullName, "Mods"));
var paths = new
{
executable = Path.Combine(installDir.FullName, platform == Platform.Mono ? "StardewValley.exe" : "Stardew Valley.exe"),
@@ -125,7 +133,7 @@ namespace StardewModdingApi.Installer
****/
if (!packageDir.Exists)
{
- this.ExitError($"The '{platform}' package directory is missing (should be at {packageDir}).");
+ this.ExitError($"The 'internal/{platform}' package folder is missing (should be at {packageDir}).");
return;
}
if (!File.Exists(paths.executable))
@@ -139,11 +147,9 @@ namespace StardewModdingApi.Installer
** ask user what to do
****/
Console.WriteLine("You can....");
- Console.WriteLine(platform == Platform.Mono
- ? "[1] Install SMAPI. This will safely update the files so you can launch the game the same way as before."
- : "[1] Install SMAPI. You'll need to launch StardewModdingAPI.exe instead afterwards; see the readme.txt for details."
- );
+ Console.WriteLine("[1] Install SMAPI.");
Console.WriteLine("[2] Uninstall SMAPI.");
+ Console.WriteLine();
ScriptAction action;
{
@@ -175,8 +181,7 @@ namespace StardewModdingApi.Installer
}
// remove old files
- string[] removePaths = this.UninstallPaths
- .Select(path => Path.Combine(installDir.FullName, path))
+ string[] removePaths = this.GetUninstallPaths(installDir, modsDir)
.Where(path => Directory.Exists(path) || File.Exists(path))
.ToArray();
if (removePaths.Any())
@@ -219,7 +224,6 @@ namespace StardewModdingApi.Installer
}
// create mods directory (if needed)
- DirectoryInfo modsDir = new DirectoryInfo(Path.Combine(installDir.FullName, "Mods"));
if (!modsDir.Exists)
{
this.PrintDebug("Creating mods directory...");
diff --git a/src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj b/src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj
index 4e4872b6..e31a1452 100644
--- a/src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj
+++ b/src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj
@@ -50,47 +50,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
- <Import Project="$(SolutionDir)\crossplatform.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- package files -->
- <Target Name="AfterBuild">
- <PropertyGroup>
- <CompiledInstallerPath>$(SolutionDir)\..\bin\Packaged</CompiledInstallerPath>
- <CompiledSmapiPath>$(SolutionDir)\..\bin\$(Configuration)\SMAPI</CompiledSmapiPath>
- </PropertyGroup>
- <ItemGroup>
- <CompiledMods Include="$(SolutionDir)\..\bin\$(Configuration)\Mods\**\*.*" />
- </ItemGroup>
- <!-- reset package directory -->
- <RemoveDir Directories="$(CompiledInstallerPath)" />
- <!-- copy installer files -->
- <Copy SourceFiles="$(TargetDir)\$(TargetName).exe" DestinationFiles="$(CompiledInstallerPath)\install.exe" />
- <Copy SourceFiles="$(TargetDir)\readme.txt" DestinationFiles="$(CompiledInstallerPath)\readme.txt" />
- <!-- copy SMAPI files for Mono -->
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\Mono.Cecil.dll" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\Mono.Cecil.Rocks.dll" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\Newtonsoft.Json.dll" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.exe" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.exe.mdb" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.AssemblyRewriters.dll" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.config.json" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.data.json" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\System.Numerics.dll" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\System.Runtime.Caching.dll" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\unix-launcher.sh" DestinationFiles="$(CompiledInstallerPath)\Mono\StardewModdingAPI" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\steam_appid.txt" DestinationFolder="$(CompiledInstallerPath)\Mono" />
- <Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="@(CompiledMods)" DestinationFolder="$(CompiledInstallerPath)\Mono\Mods\%(RecursiveDir)" />
- <!-- copy SMAPI files for Windows -->
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\Mono.Cecil.dll" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\Mono.Cecil.Rocks.dll" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\Newtonsoft.Json.dll" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.exe" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.pdb" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.xml" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.AssemblyRewriters.dll" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.config.json" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\StardewModdingAPI.data.json" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\steam_appid.txt" DestinationFolder="$(CompiledInstallerPath)\Windows" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="@(CompiledMods)" DestinationFolder="$(CompiledInstallerPath)\Windows\Mods\%(RecursiveDir)" />
- </Target>
+ <Import Project="$(SolutionDir)\crossplatform.targets" />
+ <Import Project="$(SolutionDir)\prepare-install-package.targets" />
</Project> \ No newline at end of file
diff --git a/src/StardewModdingAPI.Installer/readme.txt b/src/StardewModdingAPI.Installer/readme.txt
index c5a1caa6..4756099e 100644
--- a/src/StardewModdingAPI.Installer/readme.txt
+++ b/src/StardewModdingAPI.Installer/readme.txt
@@ -1,4 +1,25 @@
-On Windows, double-click install.exe.
-On Linux or Mac, open a terminal and run `mono install.exe`.
+ ___ ___ ___ ___
+ / /\ /__/\ / /\ / /\ ___
+ / /:/_ | |::\ / /::\ / /::\ / /\
+ / /:/ /\ | |:|:\ / /:/\:\ / /:/\:\ / /:/
+ / /:/ /::\ __|__|:|\:\ / /:/~/::\ / /:/~/:/ /__/::\
+ /__/:/ /:/\:\ /__/::::| \:\ /__/:/ /:/\:\ /__/:/ /:/ \__\/\:\__
+ \ \:\/:/~/:/ \ \:\~~\__\/ \ \:\/:/__\/ \ \:\/:/ \ \:\/\
+ \ \::/ /:/ \ \:\ \ \::/ \ \::/ \__\::/
+ \__\/ /:/ \ \:\ \ \:\ \ \:\ /__/:/
+ /__/:/ \ \:\ \ \:\ \ \:\ \__\/
+ \__\/ \__\/ \__\/ \__\/
-For more detailed instructions, see http://canimod.com/guides/using-mods#installing-smapi. \ No newline at end of file
+
+SMAPI lets you run Stardew Valley with mods. Don't forget to download mods separately.
+
+
+To install:
+ - Windows: double-click install.exe.
+ - Linux or Mac: open a terminal and run `mono install.exe`.
+
+
+Need help? See:
+ - Install guide: http://canimod.com/guides/using-mods#installing-smapi
+ - Troubleshooting: http://canimod.com/guides/smapi-faq#troubleshooting
+ - Ask for help: https://discord.gg/kH55QXP