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. --- 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 ---------------------- 6 files changed, 61 insertions(+), 86 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/assets') 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/assets') 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/assets') 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