From f6479ea2b61ebcc4eda434d7d5cb664534a99801 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 17 Aug 2021 16:42:04 -0400 Subject: restructure installer for .NET 5 changes --- src/SMAPI.Installer/assets/windows-install.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI.Installer/assets/windows-install.bat') diff --git a/src/SMAPI.Installer/assets/windows-install.bat b/src/SMAPI.Installer/assets/windows-install.bat index 2cd98554..3ca13528 100644 --- a/src/SMAPI.Installer/assets/windows-install.bat +++ b/src/SMAPI.Installer/assets/windows-install.bat @@ -4,5 +4,5 @@ if not errorlevel 1 ( echo Oops! It looks like you're running the installer from inside a zip file. Make sure you unzip the download first. pause ) else ( - start /WAIT /B internal\windows-install.exe + start /WAIT /B internal\windows\install.exe ) -- cgit From 7c5c63d6846d93f772dfda37f394b5f501f49f25 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 17 Aug 2021 20:11:30 -0400 Subject: fix SMAPI not working on macOS, improve installer validation --- build/prepare-install-package.targets | 2 -- src/SMAPI.Installer/assets/unix-install.sh | 10 ++++--- src/SMAPI.Installer/assets/unix-launcher.sh | 36 ++++++++++++++++++++++++-- src/SMAPI.Installer/assets/windows-install.bat | 29 +++++++++++++++++---- 4 files changed, 65 insertions(+), 12 deletions(-) (limited to 'src/SMAPI.Installer/assets/windows-install.bat') diff --git a/build/prepare-install-package.targets b/build/prepare-install-package.targets index dd28266d..ef5624ad 100644 --- a/build/prepare-install-package.targets +++ b/build/prepare-install-package.targets @@ -38,8 +38,6 @@ - - diff --git a/src/SMAPI.Installer/assets/unix-install.sh b/src/SMAPI.Installer/assets/unix-install.sh index f5de7b16..07df4e6c 100644 --- a/src/SMAPI.Installer/assets/unix-install.sh +++ b/src/SMAPI.Installer/assets/unix-install.sh @@ -3,8 +3,12 @@ # Move to script's directory cd "`dirname "$0"`" -# if $TERM is not set to xterm, mono will bail out when attempting to write to the console. -export TERM=xterm +# 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 -./internal/unix/install +dotnet internal/unix/SMAPI.Installer.dll diff --git a/src/SMAPI.Installer/assets/unix-launcher.sh b/src/SMAPI.Installer/assets/unix-launcher.sh index 21bed803..0e700b61 100644 --- a/src/SMAPI.Installer/assets/unix-launcher.sh +++ b/src/SMAPI.Installer/assets/unix-launcher.sh @@ -10,7 +10,15 @@ if [ ! -f "Stardew Valley.dll" ]; then exit 1 fi +# 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 + # macOS +UNAME=$(uname) if [ "$UNAME" == "Darwin" ]; then # fix "DllNotFoundException: libgdiplus.dylib" errors when loading images in SMAPI if [ -f libgdiplus.dylib ]; then @@ -20,8 +28,32 @@ if [ "$UNAME" == "Darwin" ]; then ln -s /Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib libgdiplus.dylib fi - # launch smapi - open -a Terminal ./StardewModdingAPI "$@" + # Make sure we're running in Terminal (so the user can see errors/warnings/update alerts). + if [ ! -t 1 ]; then # https://stackoverflow.com/q/911168/262123 + # sanity check to make sure we don't have an infinite loop of opening windows + SKIP_TERMINAL=false + for argument in "$@"; do + if [ "$argument" == "--no-reopen-terminal" ]; then + SKIP_TERMINAL=true + break + fi + done + + # reopen in Terminal if needed + # https://stackoverflow.com/a/29511052/262123 + if [ "$SKIP_TERMINAL" == "false" ]; then + echo "Reopening in the Terminal app..." + echo "\"$0\" $@ --no-reopen-terminal" > /tmp/open-smapi-terminal.sh + chmod +x /tmp/open-smapi-terminal.sh + cat /tmp/open-smapi-terminal.sh + open -W -a Terminal /tmp/open-smapi-terminal.sh + rm /tmp/open-smapi-terminal.sh + exit 0 + fi + fi + + # launch SMAPI + dotnet StardewModdingAPI.dll "$@" # Linux else diff --git a/src/SMAPI.Installer/assets/windows-install.bat b/src/SMAPI.Installer/assets/windows-install.bat index 3ca13528..8623f321 100644 --- a/src/SMAPI.Installer/assets/windows-install.bat +++ b/src/SMAPI.Installer/assets/windows-install.bat @@ -1,8 +1,27 @@ @echo off + +REM make sure we're not running within a zip folder echo "%~dp0" | findstr /C:"%TEMP%" 1>nul -if not errorlevel 1 ( - echo Oops! It looks like you're running the installer from inside a zip file. Make sure you unzip the download first. - pause -) else ( - start /WAIT /B internal\windows\install.exe +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." + pause + exit ) + +REM make sure .NET 5 is installed +WHERE dotnet /q +if %ERRORLEVEL% NEQ 0 ( + echo "Oops! You must have .NET 5 (desktop x64) installed to use SMAPI: https://dotnet.microsoft.com/download/dotnet/5.0/runtime" + pause + exit +) + +REM make sure an antivirus hasn't deleted the installer DLL +if not exist internal\windows\SMAPI.Installer.dll ( + echo "Oops! SMAPI can't find its 'internal\windows\SMAPI.Installer.dll' file. Your antivirus might have deleted the file." + pause + exit +) + +REM start installer +dotnet internal\windows\SMAPI.Installer.dll -- cgit From b791e854c1f2117f0cc218485ec767a493a3d847 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 23 Sep 2021 23:11:54 -0400 Subject: fix installer precheck errors showing quotes, tweak readability --- src/SMAPI.Installer/assets/windows-install.bat | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/SMAPI.Installer/assets/windows-install.bat') diff --git a/src/SMAPI.Installer/assets/windows-install.bat b/src/SMAPI.Installer/assets/windows-install.bat index 8623f321..00a2c6fb 100644 --- a/src/SMAPI.Installer/assets/windows-install.bat +++ b/src/SMAPI.Installer/assets/windows-install.bat @@ -3,7 +3,8 @@ REM make sure we're not running within a zip folder echo "%~dp0" | 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 Oops! It looks like you're running the installer from inside a zip file. Make sure you unzip the download first. + echo. pause exit ) @@ -11,14 +12,17 @@ if %ERRORLEVEL% EQU 0 ( REM make sure .NET 5 is installed WHERE dotnet /q if %ERRORLEVEL% NEQ 0 ( - echo "Oops! You must have .NET 5 (desktop x64) installed to use SMAPI: https://dotnet.microsoft.com/download/dotnet/5.0/runtime" + echo Oops! You must have .NET 5 ^(desktop x64^) installed to use SMAPI: https://dotnet.microsoft.com/download/dotnet/5.0/runtime + echo. pause exit ) REM make sure an antivirus hasn't deleted the installer DLL if not exist internal\windows\SMAPI.Installer.dll ( - echo "Oops! SMAPI can't find its 'internal\windows\SMAPI.Installer.dll' file. Your antivirus might have deleted the file." + 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 ) -- cgit From 32ccc8e87294fae4caaf7878ee852ab89b9cfdfd Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 23 Sep 2021 23:12:43 -0400 Subject: fix installer file precheck failing for some users --- src/SMAPI.Installer/assets/windows-install.bat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/SMAPI.Installer/assets/windows-install.bat') diff --git a/src/SMAPI.Installer/assets/windows-install.bat b/src/SMAPI.Installer/assets/windows-install.bat index 00a2c6fb..bd6da962 100644 --- a/src/SMAPI.Installer/assets/windows-install.bat +++ b/src/SMAPI.Installer/assets/windows-install.bat @@ -1,7 +1,9 @@ @echo off +SET installerDir=%~dp0 + REM make sure we're not running within a zip folder -echo "%~dp0" | findstr /C:"%TEMP%" 1>nul +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. @@ -19,7 +21,7 @@ if %ERRORLEVEL% NEQ 0 ( ) REM make sure an antivirus hasn't deleted the installer DLL -if not exist internal\windows\SMAPI.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. -- cgit From 51c6ef9443c9d53448d39a97afde8a0fd23eec46 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 23 Sep 2021 23:13:17 -0400 Subject: fix .NET 5 precheck passing if player has .NET Core installed --- src/SMAPI.Installer/assets/windows-install.bat | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/SMAPI.Installer/assets/windows-install.bat') diff --git a/src/SMAPI.Installer/assets/windows-install.bat b/src/SMAPI.Installer/assets/windows-install.bat index bd6da962..cb96fc19 100644 --- a/src/SMAPI.Installer/assets/windows-install.bat +++ b/src/SMAPI.Installer/assets/windows-install.bat @@ -19,6 +19,13 @@ if %ERRORLEVEL% NEQ 0 ( pause exit ) +dotnet --info | findstr /C:"Microsoft.WindowsDesktop.App 5." 1>nul +if %ERRORLEVEL% NEQ 0 ( + echo Oops! You must have .NET 5 ^(desktop x64^) installed to use SMAPI: https://dotnet.microsoft.com/download/dotnet/5.0/runtime + echo. + pause + exit +) REM make sure an antivirus hasn't deleted the installer DLL if not exist "%installerDir%internal\windows\SMAPI.Installer.dll" ( -- cgit From cb378a1c558dc2c5de9f2ab1ae9ba38b17d2ac7c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 23 Sep 2021 23:25:51 -0400 Subject: keep installer window open if it crashes --- docs/release-notes.md | 1 + src/SMAPI.Installer/assets/windows-install.bat | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'src/SMAPI.Installer/assets/windows-install.bat') diff --git a/docs/release-notes.md b/docs/release-notes.md index d6e22af4..f8c1b495 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -6,6 +6,7 @@ * Updated for Stardew Valley 1.5.5. * Updated compatibility list. * Added `set_farm_type` [console command](https://stardewvalleywiki.com/Modding:Console_commands#Console_commands) to change the current farm type. + * Fixed installer window closing immediately if the installer crashed. * For mod authors: * Migrated to 64-bit MonoGame and .NET 5 on all platforms (see [migration guide for mod authors](https://stardewvalleywiki.com/Modding:Migrate_to_Stardew_Valley_1.5.5)). diff --git a/src/SMAPI.Installer/assets/windows-install.bat b/src/SMAPI.Installer/assets/windows-install.bat index cb96fc19..2e0be906 100644 --- a/src/SMAPI.Installer/assets/windows-install.bat +++ b/src/SMAPI.Installer/assets/windows-install.bat @@ -38,3 +38,12 @@ if not exist "%installerDir%internal\windows\SMAPI.Installer.dll" ( 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