fix SMAPI not working on macOS, improve installer validation

This commit is contained in:
Jesse Plamondon-Willard 2021-08-17 20:11:30 -04:00
parent f6479ea2b6
commit 7c5c63d684
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
4 changed files with 65 additions and 12 deletions

View File

@ -38,8 +38,6 @@
<Copy SourceFiles="$(TargetDir)\assets\README.txt" DestinationFolder="$(PackagePath)" />
<Copy SourceFiles="$(TargetDir)\assets\windows-exe-config.xml" DestinationFiles="$(PackagePath)\internal\$(PlatformName)\install.exe.config" Condition="$(PlatformName) == 'windows'" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).dll" DestinationFolder="$(PackagePath)\internal\$(PlatformName)" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).exe" DestinationFiles="$(PackagePath)\internal\$(PlatformName)\install.exe" Condition="$(PlatformName) == 'windows'" />
<Copy SourceFiles="$(TargetDir)\$(TargetName)" DestinationFiles="$(PackagePath)\internal\$(PlatformName)\install" Condition="$(PlatformName) != 'windows'" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).runtimeconfig.json" DestinationFolder="$(PackagePath)\internal\$(PlatformName)" />
<!--copy bundle files-->

View File

@ -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

View File

@ -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

View File

@ -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