From bf5a9b87627b04523c7885b503e85ca2021c63a3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 2 Dec 2021 20:48:00 -0500 Subject: switch to scripted release package process --- src/SMAPI.Installer/SMAPI.Installer.csproj | 1 - 1 file changed, 1 deletion(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/SMAPI.Installer.csproj b/src/SMAPI.Installer/SMAPI.Installer.csproj index e3e01467..928e5c18 100644 --- a/src/SMAPI.Installer/SMAPI.Installer.csproj +++ b/src/SMAPI.Installer/SMAPI.Installer.csproj @@ -17,5 +17,4 @@ - -- cgit From 181508084b5bb2bb7b8cd61ec3193a293300ba45 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 3 Dec 2021 00:26:46 -0500 Subject: make installer self-contained This lets players run the installer without manually installing .NET 5, which was causing a lot of support requests. --- build/prepare-install-package.sh | 41 ++++++++------ docs/release-notes.md | 3 + src/SMAPI.Installer/assets/README.txt | 18 +++--- src/SMAPI.Installer/assets/install on Linux.sh | 4 ++ src/SMAPI.Installer/assets/install on Windows.bat | 41 ++++++++++++++ .../assets/install on macOS.command | 6 ++ src/SMAPI.Installer/assets/unix-install.sh | 14 ----- src/SMAPI.Installer/assets/windows-install.bat | 64 ---------------------- 8 files changed, 87 insertions(+), 104 deletions(-) create mode 100644 src/SMAPI.Installer/assets/install on Linux.sh create mode 100644 src/SMAPI.Installer/assets/install on Windows.bat create mode 100644 src/SMAPI.Installer/assets/install on macOS.command delete mode 100644 src/SMAPI.Installer/assets/unix-install.sh delete mode 100644 src/SMAPI.Installer/assets/windows-install.bat (limited to 'src/SMAPI.Installer') diff --git a/build/prepare-install-package.sh b/build/prepare-install-package.sh index c16fcd5f..2d03ba82 100755 --- a/build/prepare-install-package.sh +++ b/build/prepare-install-package.sh @@ -3,12 +3,15 @@ ########## ## Constants ########## +# paths gamePath="/home/pathoschild/Stardew Valley" bundleModNames=("ConsoleCommands" "ErrorHandler" "SaveBackup") + +# build configuration buildConfig="Release" -folders=("unix" "windows") -declare -A runtimes=(["unix"]="linux-x64" ["windows"]="win-x64") -declare -A msBuildPlatformNames=(["unix"]="Unix" ["windows"]="Windows_NT") +folders=("linux" "macOS" "windows") +declare -A runtimes=(["linux"]="linux-x64" ["macOS"]="osx-x64" ["windows"]="win-x64") +declare -A msBuildPlatformNames=(["linux"]="Unix" ["macOS"]="OSX" ["windows"]="Windows_NT") ########## @@ -44,7 +47,7 @@ for folder in ${folders[@]}; do echo "Compiling installer for $folder..." echo "----------------------" - dotnet publish src/SMAPI.Installer --configuration $buildConfig -v minimal --runtime "$runtime" -p:OS="$msbuildPlatformName" -p:GamePath="$gamePath" -p:CopyToGameFolder="false" + dotnet publish src/SMAPI.Installer --configuration $buildConfig -v minimal --runtime "$runtime" -p:OS="$msbuildPlatformName" -p:GamePath="$gamePath" -p:CopyToGameFolder="false" -p:PublishTrimmed=True -p:TrimMode=Link --self-contained true echo "" echo "" @@ -75,29 +78,32 @@ for folder in ${folders[@]}; do done # copy base installer files -cp "$installAssets/unix-install.sh" "$packagePath/install on Linux.sh" -cp "$installAssets/unix-install.sh" "$packagePath/install on macOS.command" -cp "$installAssets/windows-install.bat" "$packagePath/install on Windows.bat" -cp "$installAssets/README.txt" "$packagePath/README.txt" +for name in "install on Linux.sh" "install on macOS.command" "install on Windows.bat" "README.txt"; do + cp "$installAssets/$name" "$packagePath/$name" +done # copy per-platform files for folder in ${folders[@]}; do runtime=${runtimes[$folder]} # get paths - installBin="src/SMAPI.Installer/bin/$buildConfig/$runtime" - smapiBin="src/SMAPI/bin/$buildConfig/$runtime" + smapiBin="src/SMAPI/bin/$buildConfig/$runtime/publish" internalPath="$packagePath/internal/$folder" bundlePath="$internalPath/bundle" - # runtime config for installer - cp "$installBin/SMAPI.Installer.runtimeconfig.json" "$internalPath/SMAPI.Installer.runtimeconfig.json" + # installer files + cp -r "src/SMAPI.Installer/bin/$buildConfig/$runtime/publish"/* "$internalPath" + rm -rf "$internalPath/ref" + rm -rf "$internalPath/assets" # runtime config for SMAPI - cp "$installAssets/runtimeconfig.$folder.json" "$bundlePath/StardewModdingAPI.runtimeconfig.json" + if [ $folder == "linux" ] || [ $folder == "macOS" ]; then + cp "$installAssets/runtimeconfig.unix.json" "$bundlePath/StardewModdingAPI.runtimeconfig.json" + else + cp "$installAssets/runtimeconfig.$folder.json" "$bundlePath/StardewModdingAPI.runtimeconfig.json" + fi - # installer DLL - cp "$installBin/SMAPI.Installer.dll" "$internalPath/SMAPI.Installer.dll" + # installer DLL config if [ $folder == "windows" ]; then cp "$installAssets/windows-exe-config.xml" "$packagePath/internal/windows/install.exe.config" fi @@ -121,7 +127,7 @@ for folder in ${folders[@]}; do cp "$smapiBin/SMAPI.config.json" "$bundlePath/smapi-internal/config.json" cp "$smapiBin/SMAPI.metadata.json" "$bundlePath/smapi-internal/metadata.json" - if [ $folder == "unix" ]; then + if [ $folder == "linux" ] || [ $folder == "macOS" ]; then cp "$installAssets/unix-launcher.sh" "$bundlePath/unix-launcher.sh" cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal/System.Runtime.Caching.dll" else @@ -138,7 +144,7 @@ for folder in ${folders[@]}; do # copy bundled mods for modName in ${bundleModNames[@]}; do - fromPath="src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime" + fromPath="src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime/publish" targetPath="$bundlePath/Mods/$modName" mkdir "$targetPath" --parents @@ -190,7 +196,6 @@ fi mv "$packagePath" "bin/SMAPI $version installer" mv "$packageDevPath" "bin/SMAPI $version installer for developers" - # package files pushd bin > /dev/null zip -9 "SMAPI $version installer.zip" "SMAPI $version installer" --recurse-paths --quiet diff --git a/docs/release-notes.md b/docs/release-notes.md index cb52f814..09bbf832 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,9 @@ # Release notes ## Upcoming version +* For players: + * You no longer need .NET 5 to run the SMAPI installer. + * 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/assets/README.txt b/src/SMAPI.Installer/assets/README.txt index 5c20529a..08e99887 100644 --- a/src/SMAPI.Installer/assets/README.txt +++ b/src/SMAPI.Installer/assets/README.txt @@ -14,22 +14,27 @@ SMAPI lets you run Stardew Valley with mods. Don't forget to download mods separately. -Player's guide +Automated install -------------------------------- See https://stardewvalleywiki.com/Modding:Player_Guide for help installing SMAPI, adding mods, etc. Manual install -------------------------------- -THIS IS NOT RECOMMENDED FOR MOST PLAYERS. See instructions above instead. +THIS IS NOT RECOMMENDED FOR MOST PLAYERS. See the instructions above instead. If you really want to install SMAPI manually, here's how. -1. Unzip "internal/windows/install.dat" (on Windows) or "internal/unix/install.dat" (on - Linux/macOS). You can change '.dat' to '.zip', it's just a normal zip file renamed to prevent +1. Unzip "internal/windows/install.dat" (on Windows) or "internal/unix/install.dat" (on Linux or + macOS). You can change '.dat' to '.zip', it's just a normal zip file renamed to prevent confusion. + 2. Copy the files from the folder you just unzipped into your game folder. The `StardewModdingAPI.exe` file should be right next to the game's executable. -3. + +3. Copy `Stardew Valley.deps.json` in the game folder, and rename the copy to + `StardewModdingAPI.deps.json`. + +4. - Windows only: if you use Steam, see the install guide above to enable achievements and overlay. Otherwise, just run StardewModdingAPI.exe in your game folder to play with mods. @@ -38,8 +43,5 @@ If you really want to install SMAPI manually, here's how. play with mods. When installing on Linux or macOS: -- Make sure Mono is installed (normally the installer checks for you). While it's not required, - many mods won't work correctly without it. (Specifically, mods which load PNG images may crash or - freeze the game.) - To configure the color scheme, edit the `smapi-internal/config.json` file and see instructions there for the 'ColorScheme' setting. diff --git a/src/SMAPI.Installer/assets/install on Linux.sh b/src/SMAPI.Installer/assets/install on Linux.sh new file mode 100644 index 00000000..3b7eae9c --- /dev/null +++ b/src/SMAPI.Installer/assets/install on Linux.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd "`dirname "$0"`" +internal/linux/SMAPI.Installer diff --git a/src/SMAPI.Installer/assets/install on Windows.bat b/src/SMAPI.Installer/assets/install on Windows.bat new file mode 100644 index 00000000..b0d9ae81 --- /dev/null +++ b/src/SMAPI.Installer/assets/install on Windows.bat @@ -0,0 +1,41 @@ +@echo off +setlocal enabledelayedexpansion + +SET installerDir="%~dp0" + +REM make sure we're not running within a zip folder +echo %installerDir% | findstr /C:"%TEMP%" 1>nul +if %ERRORLEVEL% EQU 0 ( + echo Oops! It looks like you're running the installer from inside a zip file. Make sure you unzip the download first. + echo. + pause + exit +) + +REM make sure an antivirus hasn't deleted the installer DLL +if not exist %installerDir%"internal\windows\SMAPI.Installer.dll" ( + echo Oops! SMAPI is missing one of its files. Your antivirus might have deleted it. + echo Missing file: %installerDir%internal\windows\SMAPI.Installer.dll + echo. + pause + exit +) +if not exist %installerDir%"internal\windows\SMAPI.Installer.exe" ( + echo Oops! SMAPI is missing one of its files. Your antivirus might have deleted it. + echo Missing file: %installerDir%internal\windows\SMAPI.Installer.exe + echo. + pause + exit +) + +REM start installer +internal\windows\SMAPI.Installer.exe + +REM keep window open if it failed +if %ERRORLEVEL% NEQ 0 ( + echo. + echo Oops! The SMAPI installer seems to have failed. The error details may be shown above. + echo. + pause + exit +) diff --git a/src/SMAPI.Installer/assets/install on macOS.command b/src/SMAPI.Installer/assets/install on macOS.command new file mode 100644 index 00000000..abd21dc8 --- /dev/null +++ b/src/SMAPI.Installer/assets/install on macOS.command @@ -0,0 +1,6 @@ +#!/bin/bash + +cd "`dirname "$0"`" + +xattr -r -d com.apple.quarantine internal +internal/macOS/SMAPI.Installer diff --git a/src/SMAPI.Installer/assets/unix-install.sh b/src/SMAPI.Installer/assets/unix-install.sh deleted file mode 100644 index 07df4e6c..00000000 --- a/src/SMAPI.Installer/assets/unix-install.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Move to script's directory -cd "`dirname "$0"`" - -# make sure .NET 5 is installed -if ! command -v dotnet >/dev/null 2>&1; then - echo "Oops! You must have .NET 5 installed to use SMAPI: https://dotnet.microsoft.com/download"; - read - exit 1 -fi - -# run installer -dotnet internal/unix/SMAPI.Installer.dll diff --git a/src/SMAPI.Installer/assets/windows-install.bat b/src/SMAPI.Installer/assets/windows-install.bat deleted file mode 100644 index e34b9554..00000000 --- a/src/SMAPI.Installer/assets/windows-install.bat +++ /dev/null @@ -1,64 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -SET installerDir="%~dp0" - -REM make sure we're not running within a zip folder -echo %installerDir% | findstr /C:"%TEMP%" 1>nul -if %ERRORLEVEL% EQU 0 ( - echo Oops! It looks like you're running the installer from inside a zip file. Make sure you unzip the download first. - echo. - pause - exit -) - -REM make sure .NET 5 is installed -SET hasNet5=1 -WHERE dotnet /q -if !ERRORLEVEL! NEQ 0 ( - SET hasNet5=0 -) else ( - dotnet --info | findstr /C:"Microsoft.WindowsDesktop.App 5." 1>nul - if !ERRORLEVEL! NEQ 0 ( - SET hasNet5=0 - ) -) -if "%hasNet5%" == "0" ( - echo Oops! You don't have the required .NET version installed. - echo. - echo To install it: - echo 1. Go to https://dotnet.microsoft.com/download/dotnet/5.0/runtime - - if "%PROCESSOR_ARCHITECTURE%" == "ARM64" ( - echo 2. Under "Run desktop apps", click "Download Arm64". - ) else ( - echo 2. Under "Run desktop apps", click "Download x64". - ) - - echo 3. Run the downloaded installer. - echo 4. Restart your computer. - echo. - pause - exit -) - -REM make sure an antivirus hasn't deleted the installer DLL -if not exist %installerDir%"internal\windows\SMAPI.Installer.dll" ( - echo Oops! SMAPI is missing one of its files. Your antivirus might have deleted it. - echo Missing file: %installerDir%internal\windows\SMAPI.Installer.dll - echo. - pause - exit -) - -REM start installer -dotnet internal\windows\SMAPI.Installer.dll - -REM keep window open if it failed -if %ERRORLEVEL% NEQ 0 ( - echo. - echo Oops! The SMAPI installer seems to have failed. The error details may be shown above. - echo. - pause - exit -) -- cgit From c80d07fddfffe4fd3f8fa69bf6cab6374eec992d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 4 Dec 2021 15:55:29 -0500 Subject: migrate SMAPI to self-contained install This removes the need to have .NET 5 installed to run SMAPI. Note that there's no need to actually bundle the .NET files, since they're already bundled into the game folder. --- build/prepare-install-package.sh | 28 +++++++++++----------- docs/release-notes.md | 2 +- src/SMAPI.Installer/assets/runtimeconfig.unix.json | 3 ++- .../assets/runtimeconfig.windows.json | 3 ++- src/SMAPI.Installer/assets/unix-launcher.sh | 9 +------ 5 files changed, 20 insertions(+), 25 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/build/prepare-install-package.sh b/build/prepare-install-package.sh index 2d03ba82..07dae217 100755 --- a/build/prepare-install-package.sh +++ b/build/prepare-install-package.sh @@ -26,6 +26,7 @@ cd "`dirname "$0"`/.." echo "Clearing old builds..." echo "-----------------------" for path in */**/bin */**/obj; do + echo "$path" rm -rf $path done rm -rf "bin" @@ -38,10 +39,9 @@ for folder in ${folders[@]}; do runtime=${runtimes[$folder]} msbuildPlatformName=${msBuildPlatformNames[$folder]} - # SMAPI echo "Compiling SMAPI for $folder..." echo "------------------" - dotnet publish src/SMAPI --configuration $buildConfig -v minimal --runtime "$runtime" -p:OS="$msbuildPlatformName" -p:GamePath="$gamePath" -p:CopyToGameFolder="false" + dotnet publish src/SMAPI --configuration $buildConfig -v minimal --runtime "$runtime" -p:OS="$msbuildPlatformName" -p:GamePath="$gamePath" -p:CopyToGameFolder="false" --self-contained true echo "" echo "" @@ -79,7 +79,7 @@ done # copy base installer files for name in "install on Linux.sh" "install on macOS.command" "install on Windows.bat" "README.txt"; do - cp "$installAssets/$name" "$packagePath/$name" + cp "$installAssets/$name" "$packagePath" done # copy per-platform files @@ -114,7 +114,7 @@ for folder in ${folders[@]}; do name="$name.exe" fi - cp "$smapiBin/$name" "$bundlePath/$name" + cp "$smapiBin/$name" "$bundlePath" done # bundle i18n @@ -122,24 +122,24 @@ for folder in ${folders[@]}; do # bundle smapi-internal for name in "0Harmony.dll" "0Harmony.xml" "Mono.Cecil.dll" "Mono.Cecil.Mdb.dll" "Mono.Cecil.Pdb.dll" "MonoMod.Common.dll" "Newtonsoft.Json.dll" "TMXTile.dll" "SMAPI.Toolkit.dll" "SMAPI.Toolkit.pdb" "SMAPI.Toolkit.xml" "SMAPI.Toolkit.CoreInterfaces.dll" "SMAPI.Toolkit.CoreInterfaces.pdb" "SMAPI.Toolkit.CoreInterfaces.xml"; do - cp "$smapiBin/$name" "$bundlePath/smapi-internal/$name" + cp "$smapiBin/$name" "$bundlePath/smapi-internal" done cp "$smapiBin/SMAPI.config.json" "$bundlePath/smapi-internal/config.json" cp "$smapiBin/SMAPI.metadata.json" "$bundlePath/smapi-internal/metadata.json" if [ $folder == "linux" ] || [ $folder == "macOS" ]; then - cp "$installAssets/unix-launcher.sh" "$bundlePath/unix-launcher.sh" - cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal/System.Runtime.Caching.dll" + cp "$installAssets/unix-launcher.sh" "$bundlePath" + cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal" else cp "$installAssets/windows-exe-config.xml" "$bundlePath/StardewModdingAPI.exe.config" fi # copy .NET dependencies - cp "$smapiBin/System.Configuration.ConfigurationManager.dll" "$bundlePath/smapi-internal/System.Configuration.ConfigurationManager.dll" - cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal/System.Runtime.Caching.dll" - cp "$smapiBin/System.Security.Permissions.dll" "$bundlePath/smapi-internal/System.Security.Permissions.dll" + cp "$smapiBin/System.Configuration.ConfigurationManager.dll" "$bundlePath/smapi-internal" + cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal" + cp "$smapiBin/System.Security.Permissions.dll" "$bundlePath/smapi-internal" if [ $folder == "windows" ]; then - cp "$smapiBin/System.Management.dll" "$bundlePath/smapi-internal/System.Management.dll" + cp "$smapiBin/System.Management.dll" "$bundlePath/smapi-internal" fi # copy bundled mods @@ -149,9 +149,9 @@ for folder in ${folders[@]}; do mkdir "$targetPath" --parents - cp "$fromPath/$modName.dll" "$targetPath/$modName.dll" - cp "$fromPath/$modName.pdb" "$targetPath/$modName.pdb" - cp "$fromPath/manifest.json" "$targetPath/manifest.json" + cp "$fromPath/$modName.dll" "$targetPath" + cp "$fromPath/$modName.pdb" "$targetPath" + cp "$fromPath/manifest.json" "$targetPath" if [ -d "$fromPath/i18n" ]; then cp -r "$fromPath/i18n" "$targetPath" fi diff --git a/docs/release-notes.md b/docs/release-notes.md index 3f13b4e2..4fc6a524 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -3,7 +3,7 @@ # Release notes ## Upcoming version * For players: - * You no longer need .NET 5 to run the SMAPI installer. + * 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. * For SMAPI maintainers: diff --git a/src/SMAPI.Installer/assets/runtimeconfig.unix.json b/src/SMAPI.Installer/assets/runtimeconfig.unix.json index 8a01ceb1..a1d060b5 100644 --- a/src/SMAPI.Installer/assets/runtimeconfig.unix.json +++ b/src/SMAPI.Installer/assets/runtimeconfig.unix.json @@ -4,7 +4,8 @@ "includedFrameworks": [ { "name": "Microsoft.NETCore.App", - "version": "5.0.7" + "version": "5.0.0", + "rollForward": "major" } ], "configProperties": { diff --git a/src/SMAPI.Installer/assets/runtimeconfig.windows.json b/src/SMAPI.Installer/assets/runtimeconfig.windows.json index b693d809..d5f24bdb 100644 --- a/src/SMAPI.Installer/assets/runtimeconfig.windows.json +++ b/src/SMAPI.Installer/assets/runtimeconfig.windows.json @@ -3,7 +3,8 @@ "tfm": "net5.0", "framework": { "name": "Microsoft.NETCore.App", - "version": "5.0.0" + "version": "5.0.0", + "rollForward": "major" }, "configProperties": { "System.Runtime.TieredCompilation": false diff --git a/src/SMAPI.Installer/assets/unix-launcher.sh b/src/SMAPI.Installer/assets/unix-launcher.sh index 58f7a5ae..e8b9ae62 100644 --- a/src/SMAPI.Installer/assets/unix-launcher.sh +++ b/src/SMAPI.Installer/assets/unix-launcher.sh @@ -49,20 +49,13 @@ if [ ! -f "Stardew Valley.dll" ]; then exit 1 fi -# .NET 5 must be installed -if ! command -v dotnet >/dev/null 2>&1; then - echo "Oops! You must have .NET 5 installed to use SMAPI: https://dotnet.microsoft.com/download"; - read - exit 1 -fi - ########## ## Launch SMAPI ########## # macOS if [ "$(uname)" == "Darwin" ]; then - dotnet StardewModdingAPI.dll "$@" + ./StardewModdingAPI "$@" # Linux else -- cgit From cc35dbdb3d1fe0a82557857a72d842f1217812c2 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 4 Dec 2021 20:25:53 -0500 Subject: fix self-contained install on Windows --- build/prepare-install-package.sh | 9 ++++----- src/SMAPI.Installer/assets/runtimeconfig.json | 16 ++++++++++++++++ src/SMAPI.Installer/assets/runtimeconfig.unix.json | 15 --------------- src/SMAPI.Installer/assets/runtimeconfig.windows.json | 13 ------------- src/SMAPI/SMAPI.csproj | 3 +++ 5 files changed, 23 insertions(+), 33 deletions(-) create mode 100644 src/SMAPI.Installer/assets/runtimeconfig.json delete mode 100644 src/SMAPI.Installer/assets/runtimeconfig.unix.json delete mode 100644 src/SMAPI.Installer/assets/runtimeconfig.windows.json (limited to 'src/SMAPI.Installer') diff --git a/build/prepare-install-package.sh b/build/prepare-install-package.sh index 07dae217..39575c4c 100755 --- a/build/prepare-install-package.sh +++ b/build/prepare-install-package.sh @@ -97,11 +97,10 @@ for folder in ${folders[@]}; do rm -rf "$internalPath/assets" # runtime config for SMAPI - if [ $folder == "linux" ] || [ $folder == "macOS" ]; then - cp "$installAssets/runtimeconfig.unix.json" "$bundlePath/StardewModdingAPI.runtimeconfig.json" - else - cp "$installAssets/runtimeconfig.$folder.json" "$bundlePath/StardewModdingAPI.runtimeconfig.json" - fi + # This is identical to the one generated by the build, except that the min runtime version is + # set to 5.0.0 (instead of whatever version it was built with) and rollForward is set to latestMinor instead of + # minor. + cp "$installAssets/runtimeconfig.json" "$bundlePath/StardewModdingAPI.runtimeconfig.json" # installer DLL config if [ $folder == "windows" ]; then diff --git a/src/SMAPI.Installer/assets/runtimeconfig.json b/src/SMAPI.Installer/assets/runtimeconfig.json new file mode 100644 index 00000000..34018b8a --- /dev/null +++ b/src/SMAPI.Installer/assets/runtimeconfig.json @@ -0,0 +1,16 @@ +{ + "runtimeOptions": { + "tfm": "net5.0", + "includedFrameworks": [ + { + "name": "Microsoft.NETCore.App", + "version": "5.0.0", + "rollForward": "latestMinor" + } + ], + "configProperties": { + "System.Runtime.TieredCompilation": false, + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false + } + } +} diff --git a/src/SMAPI.Installer/assets/runtimeconfig.unix.json b/src/SMAPI.Installer/assets/runtimeconfig.unix.json deleted file mode 100644 index a1d060b5..00000000 --- a/src/SMAPI.Installer/assets/runtimeconfig.unix.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "runtimeOptions": { - "tfm": "net5.0", - "includedFrameworks": [ - { - "name": "Microsoft.NETCore.App", - "version": "5.0.0", - "rollForward": "major" - } - ], - "configProperties": { - "System.Runtime.TieredCompilation": false - } - } -} diff --git a/src/SMAPI.Installer/assets/runtimeconfig.windows.json b/src/SMAPI.Installer/assets/runtimeconfig.windows.json deleted file mode 100644 index d5f24bdb..00000000 --- a/src/SMAPI.Installer/assets/runtimeconfig.windows.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "runtimeOptions": { - "tfm": "net5.0", - "framework": { - "name": "Microsoft.NETCore.App", - "version": "5.0.0", - "rollForward": "major" - }, - "configProperties": { - "System.Runtime.TieredCompilation": false - } - } -} diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj index b99028da..f07ede87 100644 --- a/src/SMAPI/SMAPI.csproj +++ b/src/SMAPI/SMAPI.csproj @@ -13,6 +13,9 @@ true + + + false -- cgit From cb9d6ae5ad9252c2a36174856b28f12344d026f3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 4 Dec 2021 23:47:27 -0500 Subject: improve error when installer is pointed at a SDV 1.5.4 folder --- docs/release-notes.md | 3 ++- src/SMAPI.Installer/Framework/InstallerContext.cs | 7 ++++++ src/SMAPI.Installer/InteractiveInstaller.cs | 10 +++++++- .../Framework/GameScanning/GameScanner.cs | 27 ++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) (limited to 'src/SMAPI.Installer') 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 -- cgit From 98d01d522d488192b5d5da50d70752a8c0739a94 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 5 Dec 2021 00:51:24 -0500 Subject: improve error when installer is pointed at a compatibility-branch game folder --- docs/release-notes.md | 2 +- src/SMAPI.Installer/Framework/InstallerContext.cs | 6 +- src/SMAPI.Installer/InteractiveInstaller.cs | 65 ++++++++++++++++------ .../Framework/GameScanning/GameFolderType.cs | 21 +++++++ .../Framework/GameScanning/GameScanner.cs | 54 ++++++++++++------ 5 files changed, 111 insertions(+), 37 deletions(-) create mode 100644 src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs (limited to 'src/SMAPI.Installer') diff --git a/docs/release-notes.md b/docs/release-notes.md index aa9b488c..8c2b6a9e 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -4,7 +4,7 @@ ## Upcoming version * For players: * You no longer need .NET 5 installed to run SMAPI or the installer. - * The installer now detects when the game folder contains an incompatible older game version. + * The installer now detects when the game folder contains an incompatible legacy game version. * Updated for the latest Stardew Valley 1.5.5 hotfix. * For SMAPI maintainers: diff --git a/src/SMAPI.Installer/Framework/InstallerContext.cs b/src/SMAPI.Installer/Framework/InstallerContext.cs index 68df2001..bb973230 100644 --- a/src/SMAPI.Installer/Framework/InstallerContext.cs +++ b/src/SMAPI.Installer/Framework/InstallerContext.cs @@ -55,11 +55,11 @@ namespace StardewModdingAPI.Installer.Framework return this.GameScanner.LooksLikeGameFolder(dir); } - /// Get whether a folder seems to contain Stardew Valley 1.5.4 or earlier. + /// Get whether a folder seems to contain the game, and which version it contains if so. /// The folder to check. - public bool LooksLikeStardewValley154(DirectoryInfo dir) + public GameFolderType GetGameFolderType(DirectoryInfo dir) { - return this.GameScanner.LooksLikeStardewValley154(dir); + return this.GameScanner.GetGameFolderType(dir); } } } diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 424fe42b..6694c257 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -10,6 +10,7 @@ using StardewModdingAPI.Installer.Framework; using StardewModdingAPI.Internal.ConsoleWriting; using StardewModdingAPI.Toolkit; using StardewModdingAPI.Toolkit.Framework; +using StardewModdingAPI.Toolkit.Framework.GameScanning; using StardewModdingAPI.Toolkit.Framework.ModScanning; using StardewModdingAPI.Toolkit.Utilities; @@ -633,18 +634,39 @@ namespace StardewModdingApi.Installer // use specified path if (specifiedPath != null) { + string errorPrefix = $"You specified --game-path \"{specifiedPath}\", but"; + var dir = new DirectoryInfo(specifiedPath); if (!dir.Exists) { - this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't exist."); + this.PrintError($"{errorPrefix} that folder doesn't exist."); return null; } - if (!context.LooksLikeGameFolder(dir)) + + switch (context.GetGameFolderType(dir)) { - this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't contain the Stardew Valley executable."); - return null; + case GameFolderType.Valid: + return dir; + + case GameFolderType.Legacy154OrEarlier: + this.PrintWarning($"{errorPrefix} 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."); + return null; + + case GameFolderType.LegacyCompatibilityBranch: + this.PrintWarning($"{errorPrefix} that directory seems to have the Stardew Valley legacy 'compatibility' branch."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Please update your game to the main branch to use SMAPI."); + return null; + + case GameFolderType.NoGameFound: + this.PrintWarning($"{errorPrefix} that directory doesn't contain a Stardew Valley executable."); + return null; + + default: + this.PrintWarning($"{errorPrefix} that directory doesn't seem to contain a valid game install."); + return null; } - return dir; } // let user choose detected path @@ -702,23 +724,32 @@ namespace StardewModdingApi.Installer this.PrintWarning("That directory doesn't seem to exist."); continue; } - if (!context.LooksLikeGameFolder(directory)) + + switch (context.GetGameFolderType(directory)) { - if (context.LooksLikeStardewValley154(directory)) - { + case GameFolderType.Valid: + this.PrintInfo(" OK!"); + return directory; + + case GameFolderType.Legacy154OrEarlier: 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 - { + continue; + + case GameFolderType.LegacyCompatibilityBranch: + this.PrintWarning("That directory seems to have the Stardew Valley legacy 'compatibility' branch."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Please update your game to the main branch to use SMAPI."); + continue; + + case GameFolderType.NoGameFound: this.PrintWarning("That directory doesn't contain a Stardew Valley executable."); - } - continue; - } + continue; - // looks OK - this.PrintInfo(" OK!"); - return directory; + default: + this.PrintWarning("That directory doesn't seem to contain a valid game install."); + continue; + } } } diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs new file mode 100644 index 00000000..d18af59b --- /dev/null +++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs @@ -0,0 +1,21 @@ +namespace StardewModdingAPI.Toolkit.Framework.GameScanning +{ + /// The detected validity for a Stardew Valley game folder based on file structure heuristics. + public enum GameFolderType + { + /// The folder seems to contain a valid Stardew Valley 1.5.5+ install. + Valid, + + /// The folder doesn't contain Stardew Valley. + NoGameFound, + + /// The folder contains Stardew Valley 1.5.4 or earlier. This version uses XNA Framework and 32-bit .NET Framework 4.5.2 on Windows and Mono on Linux/macOS, and isn't compatible with current versions of SMAPI. + Legacy154OrEarlier, + + /// The folder contains Stardew Valley from the game's legacy compatibility branch, which backports newer changes to the format. + LegacyCompatibilityBranch, + + /// The folder seems to contain Stardew Valley files, but they failed to load for unknown reasons (e.g. corrupted executable). + InvalidUnknown + } +} diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs index c7ebe6e0..37e4f263 100644 --- a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs +++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs @@ -55,36 +55,58 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning /// The folder to check. public bool LooksLikeGameFolder(DirectoryInfo dir) { - return - dir.Exists - && dir.EnumerateFiles("Stardew Valley.dll").Any(); + return this.GetGameFolderType(dir) == GameFolderType.Valid; } - /// Get whether a folder seems to contain Stardew Valley 1.5.4 or earlier. + /// Detect the validity of a game folder based on file structure heuristics. /// The folder to check. - public bool LooksLikeStardewValley154(DirectoryInfo dir) + public GameFolderType GetGameFolderType(DirectoryInfo dir) { - if (!dir.Exists || this.LooksLikeGameFolder(dir)) - return false; + // no such folder + if (!dir.Exists) + return GameFolderType.NoGameFound; - // get legacy executable - FileInfo executable = new FileInfo(Path.Combine(dir.FullName, "Stardew Valley.exe")); + // apparently valid + if (dir.EnumerateFiles("Stardew Valley.dll").Any()) + return GameFolderType.Valid; + + // doesn't contain any version of Stardew Valley + FileInfo executable = new(Path.Combine(dir.FullName, "Stardew Valley.exe")); if (!executable.Exists) - executable = new FileInfo(Path.Combine(dir.FullName, "StardewValley.exe")); + executable = new(Path.Combine(dir.FullName, "StardewValley.exe")); // pre-1.5.5 Linux/macOS executable if (!executable.Exists) - return false; + return GameFolderType.NoGameFound; - // 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. + // get assembly version + Version version; try { - Version version = AssemblyName.GetAssemblyName(executable.FullName).Version; - return true; + version = AssemblyName.GetAssemblyName(executable.FullName).Version; } catch { - return false; + // The executable exists but it doesn't seem to be a valid assembly. This would + // happen with Stardew Valley 1.5.5+, but that should have been flagged as a valid + // folder before this point. + return GameFolderType.InvalidUnknown; } + + // ignore Stardew Valley 1.5.5+ at this point + if (version.Major == 1 && version.Minor == 3 && version.Build == 37) + return GameFolderType.InvalidUnknown; + + // incompatible version + if (version.Major == 1 && version.Minor < 4) + { + // Stardew Valley 1.5.4 and earlier have assembly versions <= 1.3.7853.31734 + if (version.Minor < 3 || version.Build <= 7853) + return GameFolderType.Legacy154OrEarlier; + + // Stardew Valley 1.5.5+ legacy compatibility branch + return GameFolderType.LegacyCompatibilityBranch; + } + + return GameFolderType.InvalidUnknown; } /********* -- cgit From 5b5dd47c22a1332a4c432d6a1cd414b5c83388d7 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 5 Dec 2021 19:10:28 -0500 Subject: prepare for release --- build/common.targets | 2 +- docs/release-notes.md | 8 +++++--- src/SMAPI.Installer/InteractiveInstaller.cs | 4 ++-- src/SMAPI.Mods.ConsoleCommands/manifest.json | 4 ++-- src/SMAPI.Mods.ErrorHandler/manifest.json | 4 ++-- src/SMAPI.Mods.SaveBackup/manifest.json | 4 ++-- src/SMAPI/Constants.cs | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/build/common.targets b/build/common.targets index ed860eee..1021c2a1 100644 --- a/build/common.targets +++ b/build/common.targets @@ -1,7 +1,7 @@ - 3.13.1 + 3.13.2 SMAPI latest $(AssemblySearchPaths);{GAC} diff --git a/docs/release-notes.md b/docs/release-notes.md index 8a26514d..499fa322 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,9 +1,11 @@ ← [README](README.md) # Release notes -## Upcoming version +## 3.13.2 +Released 05 December 2021 for Stardew Valley 1.5.5 or later. + * For players: - * You no longer need .NET 5 installed to run SMAPI or the installer. + * You no longer need .NET 5 to install or use SMAPI. * The installer now detects when the game folder contains an incompatible legacy game version. * Updated for the latest Stardew Valley 1.5.5 hotfix. * Updated compatibility list. @@ -12,7 +14,7 @@ * Fixed the JSON validator marking `.fnt` files invalid in Content Patcher files. * 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. + * Added [release package scripts](technical/smapi.md) to streamline preparing SMAPI releases. ## 3.13.1 Released 30 November 2021 for Stardew Valley 1.5.5 or later. diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 6694c257..1257f12b 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -655,7 +655,7 @@ namespace StardewModdingApi.Installer case GameFolderType.LegacyCompatibilityBranch: this.PrintWarning($"{errorPrefix} that directory seems to have the Stardew Valley legacy 'compatibility' branch."); - this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the modern version of the game."); this.PrintWarning("Please update your game to the main branch to use SMAPI."); return null; @@ -738,7 +738,7 @@ namespace StardewModdingApi.Installer case GameFolderType.LegacyCompatibilityBranch: this.PrintWarning("That directory seems to have the Stardew Valley legacy 'compatibility' branch."); - this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the modern version of the game."); this.PrintWarning("Please update your game to the main branch to use SMAPI."); continue; diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json index ac6ff6ea..216a4c32 100644 --- a/src/SMAPI.Mods.ConsoleCommands/manifest.json +++ b/src/SMAPI.Mods.ConsoleCommands/manifest.json @@ -1,9 +1,9 @@ { "Name": "Console Commands", "Author": "SMAPI", - "Version": "3.13.1", + "Version": "3.13.2", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.13.1" + "MinimumApiVersion": "3.13.2" } diff --git a/src/SMAPI.Mods.ErrorHandler/manifest.json b/src/SMAPI.Mods.ErrorHandler/manifest.json index e19a6a7f..beb52020 100644 --- a/src/SMAPI.Mods.ErrorHandler/manifest.json +++ b/src/SMAPI.Mods.ErrorHandler/manifest.json @@ -1,9 +1,9 @@ { "Name": "Error Handler", "Author": "SMAPI", - "Version": "3.13.1", + "Version": "3.13.2", "Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.", "UniqueID": "SMAPI.ErrorHandler", "EntryDll": "ErrorHandler.dll", - "MinimumApiVersion": "3.13.1" + "MinimumApiVersion": "3.13.2" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index 3e55ce42..2bd20a63 100644 --- a/src/SMAPI.Mods.SaveBackup/manifest.json +++ b/src/SMAPI.Mods.SaveBackup/manifest.json @@ -1,9 +1,9 @@ { "Name": "Save Backup", "Author": "SMAPI", - "Version": "3.13.1", + "Version": "3.13.2", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.13.1" + "MinimumApiVersion": "3.13.2" } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index c5ad215c..5de28f84 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -49,7 +49,7 @@ namespace StardewModdingAPI internal static int? LogScreenId { get; set; } /// SMAPI's current raw semantic version. - internal static string RawApiVersion = "3.13.1"; + internal static string RawApiVersion = "3.13.2"; } /// Contains SMAPI's constants and assumptions. -- cgit