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 --- build/common.targets | 3 +- build/prepare-install-package.sh | 201 ++++++++++++++++++++++++++++++++++ build/prepare-install-package.targets | 130 ---------------------- 3 files changed, 203 insertions(+), 131 deletions(-) create mode 100755 build/prepare-install-package.sh delete mode 100644 build/prepare-install-package.targets (limited to 'build') diff --git a/build/common.targets b/build/common.targets index 578076a9..c9a54763 100644 --- a/build/common.targets +++ b/build/common.targets @@ -8,6 +8,7 @@ $(DefineConstants);SMAPI_FOR_WINDOWS + true @@ -19,7 +20,7 @@ - + diff --git a/build/prepare-install-package.sh b/build/prepare-install-package.sh new file mode 100755 index 00000000..c16fcd5f --- /dev/null +++ b/build/prepare-install-package.sh @@ -0,0 +1,201 @@ +#!/bin/bash + +########## +## Constants +########## +gamePath="/home/pathoschild/Stardew Valley" +bundleModNames=("ConsoleCommands" "ErrorHandler" "SaveBackup") +buildConfig="Release" +folders=("unix" "windows") +declare -A runtimes=(["unix"]="linux-x64" ["windows"]="win-x64") +declare -A msBuildPlatformNames=(["unix"]="Unix" ["windows"]="Windows_NT") + + +########## +## Move to SMAPI root +########## +cd "`dirname "$0"`/.." + + +########## +## Clear old build files +########## +echo "Clearing old builds..." +echo "-----------------------" +for path in */**/bin */**/obj; do + rm -rf $path +done +rm -rf "bin" +echo "" + +########## +## Compile files +########## +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" + echo "" + echo "" + + 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" + echo "" + echo "" + + for modName in ${bundleModNames[@]}; do + echo "Compiling $modName for $folder..." + echo "----------------------------------" + dotnet publish src/SMAPI.Mods.$modName --configuration $buildConfig -v minimal --runtime "$runtime" -p:OS="$msbuildPlatformName" -p:GamePath="$gamePath" -p:CopyToGameFolder="false" + echo "" + echo "" + done +done + + +########## +## Prepare install package +########## +echo "Preparing install package..." +echo "----------------------------" + +# init paths +installAssets="src/SMAPI.Installer/assets" +packagePath="bin/SMAPI installer" +packageDevPath="bin/SMAPI installer for developers" + +# init structure +for folder in ${folders[@]}; do + mkdir "$packagePath/internal/$folder/bundle/smapi-internal" --parents +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" + +# 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" + internalPath="$packagePath/internal/$folder" + bundlePath="$internalPath/bundle" + + # runtime config for installer + cp "$installBin/SMAPI.Installer.runtimeconfig.json" "$internalPath/SMAPI.Installer.runtimeconfig.json" + + # runtime config for SMAPI + cp "$installAssets/runtimeconfig.$folder.json" "$bundlePath/StardewModdingAPI.runtimeconfig.json" + + # installer DLL + cp "$installBin/SMAPI.Installer.dll" "$internalPath/SMAPI.Installer.dll" + if [ $folder == "windows" ]; then + cp "$installAssets/windows-exe-config.xml" "$packagePath/internal/windows/install.exe.config" + fi + + # bundle root files + for name in "StardewModdingAPI" "StardewModdingAPI.dll" "StardewModdingAPI.pdb" "StardewModdingAPI.xml" "steam_appid.txt"; do + if [ $name == "StardewModdingAPI" ] && [ $folder == "windows" ]; then + name="$name.exe" + fi + + cp "$smapiBin/$name" "$bundlePath/$name" + done + + # bundle i18n + cp -r "$smapiBin/i18n" "$bundlePath/smapi-internal" + + # 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" + done + + cp "$smapiBin/SMAPI.config.json" "$bundlePath/smapi-internal/config.json" + cp "$smapiBin/SMAPI.metadata.json" "$bundlePath/smapi-internal/metadata.json" + if [ $folder == "unix" ]; then + cp "$installAssets/unix-launcher.sh" "$bundlePath/unix-launcher.sh" + cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal/System.Runtime.Caching.dll" + 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" + if [ $folder == "windows" ]; then + cp "$smapiBin/System.Management.dll" "$bundlePath/smapi-internal/System.Management.dll" + fi + + # copy bundled mods + for modName in ${bundleModNames[@]}; do + fromPath="src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime" + targetPath="$bundlePath/Mods/$modName" + + mkdir "$targetPath" --parents + + cp "$fromPath/$modName.dll" "$targetPath/$modName.dll" + cp "$fromPath/$modName.pdb" "$targetPath/$modName.pdb" + cp "$fromPath/manifest.json" "$targetPath/manifest.json" + if [ -d "$fromPath/i18n" ]; then + cp -r "$fromPath/i18n" "$targetPath" + fi + done +done + +# mark scripts executable +for path in "install on Linux.sh" "install on macOS.command" "bundle/unix-launcher.sh"; do + if [ -f "$packagePath/$path" ]; then + chmod 755 "$packagePath/$path" + fi +done + +# split into main + for-dev folders +cp -r "$packagePath" "$packageDevPath" +for folder in ${folders[@]}; do + # disable developer mode in main package + sed --in-place --expression="s/\"DeveloperMode\": true/\"DeveloperMode\": false/" "$packagePath/internal/$folder/bundle/smapi-internal/config.json" + + # convert bundle folder into final 'install.dat' files + for path in "$packagePath/internal/$folder" "$packageDevPath/internal/$folder"; do + pushd "$path/bundle" > /dev/null + zip "install.dat" * --recurse-paths --quiet + popd > /dev/null + mv "$path/bundle/install.dat" "$path/install.dat" + rm -rf "$path/bundle" + done +done + + +########## +## Create release zips +########## +# get version number +version="$1" +if [ $# -eq 0 ]; then + echo "SMAPI release version (like '4.0.0'):" + read version +fi + +# rename folders +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 +zip -9 "SMAPI $version installer for developers.zip" "SMAPI $version installer for developers" --recurse-paths --quiet +popd > /dev/null + +echo "" +echo "Done! Package created in $(pwd)/bin" diff --git a/build/prepare-install-package.targets b/build/prepare-install-package.targets deleted file mode 100644 index ef5624ad..00000000 --- a/build/prepare-install-package.targets +++ /dev/null @@ -1,130 +0,0 @@ - - - - - windows - unix - - $(SolutionDir) - $(SolutionDir)\..\bin - - $(BuildRootPath)\SMAPI\bin\$(Configuration) - $(BuildRootPath)\SMAPI.Toolkit\bin\$(Configuration)\net5.0 - $(BuildRootPath)\SMAPI.Mods.ConsoleCommands\bin\$(Configuration) - $(BuildRootPath)\SMAPI.Mods.ErrorHandler\bin\$(Configuration) - $(BuildRootPath)\SMAPI.Mods.SaveBackup\bin\$(Configuration) - - $(OutRootPath)\SMAPI installer - $(OutRootPath)\SMAPI installer for developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- 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 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'build') 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 -- cgit From e4416925f9b4d1deac521c62918d008076ac6b05 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 3 Dec 2021 02:16:27 -0500 Subject: add build script to set the release version --- build/set-smapi-version.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 build/set-smapi-version.sh (limited to 'build') diff --git a/build/set-smapi-version.sh b/build/set-smapi-version.sh new file mode 100755 index 00000000..42174cae --- /dev/null +++ b/build/set-smapi-version.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# get version number +version="$1" +if [ $# -eq 0 ]; then + echo "SMAPI release version (like '4.0.0'):" + read version +fi + +# move to SMAPI root +cd "`dirname "$0"`/.." + +# apply changes +sed "s/.+<\/Version>/$version<\/Version>/" "build/common.targets" --in-place --regexp-extended +sed "s/RawApiVersion = \".+?\";/RawApiVersion = \"$version\";/" "src/SMAPI/Constants.cs" --in-place --regexp-extended +for modName in "ConsoleCommands" "ErrorHandler" "SaveBackup"; do + sed "s/\"(Version|MinimumApiVersion)\": \".+?\"/\"\1\": \"$version\"/g" "src/SMAPI.Mods.$modName/manifest.json" --in-place --regexp-extended +done -- cgit From 711e17a4f99af29177fb250b24868b6e655dacb7 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 4 Dec 2021 15:55:16 -0500 Subject: suppress non-applicable code warnings --- build/common.targets | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'build') diff --git a/build/common.targets b/build/common.targets index c9a54763..ed860eee 100644 --- a/build/common.targets +++ b/build/common.targets @@ -9,6 +9,21 @@ $(DefineConstants);SMAPI_FOR_WINDOWS true + + + None + + + $(NoWarn);CS0436;CA1416;CS0809;NU1701 -- 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 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'build') 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 -- 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 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'build') 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 -- cgit From f4ca7dd228390f030735195357e81e5170bcd474 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 5 Dec 2021 18:55:10 -0500 Subject: add Windows build process to fix application icon until .NET bug is fixed --- build/prepare-install-package.sh | 205 ---------------------------- build/set-smapi-version.sh | 18 --- build/unix/prepare-install-package.sh | 211 +++++++++++++++++++++++++++++ build/unix/set-smapi-version.sh | 26 ++++ build/windows/finalize-install-package.sh | 67 +++++++++ build/windows/lib/in-place-regex.ps1 | 11 ++ build/windows/prepare-install-package.ps1 | 217 ++++++++++++++++++++++++++++++ build/windows/set-smapi-version.ps1 | 25 ++++ 8 files changed, 557 insertions(+), 223 deletions(-) delete mode 100755 build/prepare-install-package.sh delete mode 100755 build/set-smapi-version.sh create mode 100644 build/unix/prepare-install-package.sh create mode 100644 build/unix/set-smapi-version.sh create mode 100755 build/windows/finalize-install-package.sh create mode 100644 build/windows/lib/in-place-regex.ps1 create mode 100644 build/windows/prepare-install-package.ps1 create mode 100644 build/windows/set-smapi-version.ps1 (limited to 'build') diff --git a/build/prepare-install-package.sh b/build/prepare-install-package.sh deleted file mode 100755 index 39575c4c..00000000 --- a/build/prepare-install-package.sh +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/bash - -########## -## Constants -########## -# paths -gamePath="/home/pathoschild/Stardew Valley" -bundleModNames=("ConsoleCommands" "ErrorHandler" "SaveBackup") - -# build configuration -buildConfig="Release" -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") - - -########## -## Move to SMAPI root -########## -cd "`dirname "$0"`/.." - - -########## -## Clear old build files -########## -echo "Clearing old builds..." -echo "-----------------------" -for path in */**/bin */**/obj; do - echo "$path" - rm -rf $path -done -rm -rf "bin" -echo "" - -########## -## Compile files -########## -for folder in ${folders[@]}; do - runtime=${runtimes[$folder]} - msbuildPlatformName=${msBuildPlatformNames[$folder]} - - 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" --self-contained true - echo "" - echo "" - - 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" -p:PublishTrimmed=True -p:TrimMode=Link --self-contained true - echo "" - echo "" - - for modName in ${bundleModNames[@]}; do - echo "Compiling $modName for $folder..." - echo "----------------------------------" - dotnet publish src/SMAPI.Mods.$modName --configuration $buildConfig -v minimal --runtime "$runtime" -p:OS="$msbuildPlatformName" -p:GamePath="$gamePath" -p:CopyToGameFolder="false" - echo "" - echo "" - done -done - - -########## -## Prepare install package -########## -echo "Preparing install package..." -echo "----------------------------" - -# init paths -installAssets="src/SMAPI.Installer/assets" -packagePath="bin/SMAPI installer" -packageDevPath="bin/SMAPI installer for developers" - -# init structure -for folder in ${folders[@]}; do - mkdir "$packagePath/internal/$folder/bundle/smapi-internal" --parents -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" -done - -# copy per-platform files -for folder in ${folders[@]}; do - runtime=${runtimes[$folder]} - - # get paths - smapiBin="src/SMAPI/bin/$buildConfig/$runtime/publish" - internalPath="$packagePath/internal/$folder" - bundlePath="$internalPath/bundle" - - # installer files - cp -r "src/SMAPI.Installer/bin/$buildConfig/$runtime/publish"/* "$internalPath" - rm -rf "$internalPath/ref" - rm -rf "$internalPath/assets" - - # runtime config for SMAPI - # 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 - cp "$installAssets/windows-exe-config.xml" "$packagePath/internal/windows/install.exe.config" - fi - - # bundle root files - for name in "StardewModdingAPI" "StardewModdingAPI.dll" "StardewModdingAPI.pdb" "StardewModdingAPI.xml" "steam_appid.txt"; do - if [ $name == "StardewModdingAPI" ] && [ $folder == "windows" ]; then - name="$name.exe" - fi - - cp "$smapiBin/$name" "$bundlePath" - done - - # bundle i18n - cp -r "$smapiBin/i18n" "$bundlePath/smapi-internal" - - # 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" - 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" - 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" - 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" - fi - - # copy bundled mods - for modName in ${bundleModNames[@]}; do - fromPath="src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime/publish" - targetPath="$bundlePath/Mods/$modName" - - mkdir "$targetPath" --parents - - 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 - done -done - -# mark scripts executable -for path in "install on Linux.sh" "install on macOS.command" "bundle/unix-launcher.sh"; do - if [ -f "$packagePath/$path" ]; then - chmod 755 "$packagePath/$path" - fi -done - -# split into main + for-dev folders -cp -r "$packagePath" "$packageDevPath" -for folder in ${folders[@]}; do - # disable developer mode in main package - sed --in-place --expression="s/\"DeveloperMode\": true/\"DeveloperMode\": false/" "$packagePath/internal/$folder/bundle/smapi-internal/config.json" - - # convert bundle folder into final 'install.dat' files - for path in "$packagePath/internal/$folder" "$packageDevPath/internal/$folder"; do - pushd "$path/bundle" > /dev/null - zip "install.dat" * --recurse-paths --quiet - popd > /dev/null - mv "$path/bundle/install.dat" "$path/install.dat" - rm -rf "$path/bundle" - done -done - - -########## -## Create release zips -########## -# get version number -version="$1" -if [ $# -eq 0 ]; then - echo "SMAPI release version (like '4.0.0'):" - read version -fi - -# rename folders -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 -zip -9 "SMAPI $version installer for developers.zip" "SMAPI $version installer for developers" --recurse-paths --quiet -popd > /dev/null - -echo "" -echo "Done! Package created in $(pwd)/bin" diff --git a/build/set-smapi-version.sh b/build/set-smapi-version.sh deleted file mode 100755 index 42174cae..00000000 --- a/build/set-smapi-version.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# get version number -version="$1" -if [ $# -eq 0 ]; then - echo "SMAPI release version (like '4.0.0'):" - read version -fi - -# move to SMAPI root -cd "`dirname "$0"`/.." - -# apply changes -sed "s/.+<\/Version>/$version<\/Version>/" "build/common.targets" --in-place --regexp-extended -sed "s/RawApiVersion = \".+?\";/RawApiVersion = \"$version\";/" "src/SMAPI/Constants.cs" --in-place --regexp-extended -for modName in "ConsoleCommands" "ErrorHandler" "SaveBackup"; do - sed "s/\"(Version|MinimumApiVersion)\": \".+?\"/\"\1\": \"$version\"/g" "src/SMAPI.Mods.$modName/manifest.json" --in-place --regexp-extended -done diff --git a/build/unix/prepare-install-package.sh b/build/unix/prepare-install-package.sh new file mode 100644 index 00000000..9a89f8d4 --- /dev/null +++ b/build/unix/prepare-install-package.sh @@ -0,0 +1,211 @@ +#!/bin/bash + +# +# +# This is the Bash equivalent of ../windows/prepare-install-package.ps1. +# When making changes, both scripts should be updated. +# +# + + +########## +## Constants +########## +# paths +gamePath="/home/pathoschild/Stardew Valley" +bundleModNames=("ConsoleCommands" "ErrorHandler" "SaveBackup") + +# build configuration +buildConfig="Release" +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") + + +########## +## Move to SMAPI root +########## +cd "`dirname "$0"`/../.." + + +########## +## Clear old build files +########## +echo "Clearing old builds..." +echo "-------------------------------------------------" +for path in bin */**/bin */**/obj; do + echo "$path" + rm -rf $path +done +echo "" + +########## +## Compile files +########## +for folder in ${folders[@]}; do + runtime=${runtimes[$folder]} + msbuildPlatformName=${msBuildPlatformNames[$folder]} + + 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" --self-contained true + echo "" + echo "" + + 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" -p:PublishTrimmed=True -p:TrimMode=Link --self-contained true + echo "" + echo "" + + for modName in ${bundleModNames[@]}; do + echo "Compiling $modName for $folder..." + echo "-------------------------------------------------" + dotnet publish src/SMAPI.Mods.$modName --configuration $buildConfig -v minimal --runtime "$runtime" -p:OS="$msbuildPlatformName" -p:GamePath="$gamePath" -p:CopyToGameFolder="false" + echo "" + echo "" + done +done + + +########## +## Prepare install package +########## +echo "Preparing install package..." +echo "-------------------------------------------------" + +# init paths +installAssets="src/SMAPI.Installer/assets" +packagePath="bin/SMAPI installer" +packageDevPath="bin/SMAPI installer for developers" + +# init structure +for folder in ${folders[@]}; do + mkdir "$packagePath/internal/$folder/bundle/smapi-internal" --parents +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" +done + +# copy per-platform files +for folder in ${folders[@]}; do + runtime=${runtimes[$folder]} + + # get paths + smapiBin="src/SMAPI/bin/$buildConfig/$runtime/publish" + internalPath="$packagePath/internal/$folder" + bundlePath="$internalPath/bundle" + + # installer files + cp -r "src/SMAPI.Installer/bin/$buildConfig/$runtime/publish"/* "$internalPath" + rm -rf "$internalPath/assets" + + # runtime config for SMAPI + # 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 + cp "$installAssets/windows-exe-config.xml" "$packagePath/internal/windows/install.exe.config" + fi + + # bundle root files + for name in "StardewModdingAPI" "StardewModdingAPI.dll" "StardewModdingAPI.pdb" "StardewModdingAPI.xml" "steam_appid.txt"; do + if [ $name == "StardewModdingAPI" ] && [ $folder == "windows" ]; then + name="$name.exe" + fi + + cp "$smapiBin/$name" "$bundlePath" + done + + # bundle i18n + cp -r "$smapiBin/i18n" "$bundlePath/smapi-internal" + + # 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" + 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" + 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" + 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" + fi + + # copy bundled mods + for modName in ${bundleModNames[@]}; do + fromPath="src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime/publish" + targetPath="$bundlePath/Mods/$modName" + + mkdir "$targetPath" --parents + + 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 + done +done + +# mark scripts executable +for path in "install on Linux.sh" "install on macOS.command" "bundle/unix-launcher.sh"; do + if [ -f "$packagePath/$path" ]; then + chmod 755 "$packagePath/$path" + fi +done + +# split into main + for-dev folders +cp -r "$packagePath" "$packageDevPath" +for folder in ${folders[@]}; do + # disable developer mode in main package + sed --in-place --expression="s/\"DeveloperMode\": true/\"DeveloperMode\": false/" "$packagePath/internal/$folder/bundle/smapi-internal/config.json" + + # convert bundle folder into final 'install.dat' files + for path in "$packagePath/internal/$folder" "$packageDevPath/internal/$folder"; do + pushd "$path/bundle" > /dev/null + zip "install.dat" * --recurse-paths --quiet + popd > /dev/null + mv "$path/bundle/install.dat" "$path/install.dat" + rm -rf "$path/bundle" + done +done + + +########## +## Create release zips +########## +# get version number +version="$1" +if [ $# -eq 0 ]; then + echo "SMAPI release version (like '4.0.0'):" + read version +fi + +# rename folders +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 +zip -9 "SMAPI $version installer for developers.zip" "SMAPI $version installer for developers" --recurse-paths --quiet +popd > /dev/null + +echo "" +echo "Done! Package created in $(pwd)/bin" diff --git a/build/unix/set-smapi-version.sh b/build/unix/set-smapi-version.sh new file mode 100644 index 00000000..0c0cbeb0 --- /dev/null +++ b/build/unix/set-smapi-version.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# +# +# This is the Bash equivalent of ../windows/set-smapi-version.ps1. +# When making changes, both scripts should be updated. +# +# + + +# get version number +version="$1" +if [ $# -eq 0 ]; then + echo "SMAPI release version (like '4.0.0'):" + read version +fi + +# move to SMAPI root +cd "`dirname "$0"`/../.." + +# apply changes +sed "s/.+<\/Version>/$version<\/Version>/" "build/common.targets" --in-place --regexp-extended +sed "s/RawApiVersion = \".+?\";/RawApiVersion = \"$version\";/" "src/SMAPI/Constants.cs" --in-place --regexp-extended +for modName in "ConsoleCommands" "ErrorHandler" "SaveBackup"; do + sed "s/\"(Version|MinimumApiVersion)\": \".+?\"/\"\1\": \"$version\"/g" "src/SMAPI.Mods.$modName/manifest.json" --in-place --regexp-extended +done diff --git a/build/windows/finalize-install-package.sh b/build/windows/finalize-install-package.sh new file mode 100755 index 00000000..0996e3ed --- /dev/null +++ b/build/windows/finalize-install-package.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +########## +## Read config +########## +# get SMAPI version +version="$1" +if [ $# -eq 0 ]; then + echo "SMAPI release version (like '4.0.0'):" + read version +fi + +# get Windows bin path +windowsBinPath="$2" +if [ $# -le 1 ]; then + echo "Windows compiled bin path:" + read windowsBinPath +fi + +# installer internal folders +buildFolders=("linux" "macOS" "windows") + + +########## +## Finalize release package +########## +for folderName in "SMAPI $version installer" "SMAPI $version installer for developers"; do + # move files to Linux filesystem + echo "Preparing $folderName.zip..." + echo "-------------------------------------------------" + echo "copying '$windowsBinPath/$folderName' to Linux filesystem..." + cp -r "$windowsBinPath/$folderName" . + + # fix permissions + echo "fixing permissions..." + find "$folderName" -type d -exec chmod 755 {} \; + find "$folderName" -type f -exec chmod 644 {} \; + find "$folderName" -name "*.sh" -exec chmod 755 {} \; + find "$folderName" -name "*.command" -exec chmod 755 {} \; + find "$folderName" -name "SMAPI.Installer" -exec chmod 755 {} \; + find "$folderName" -name "StardewModdingAPI" -exec chmod 755 {} \; + + # convert bundle folder into final 'install.dat' files + for build in ${buildFolders[@]}; do + echo "packaging $folderName/internal/$build/install.dat..." + pushd "$folderName/internal/$build/bundle" > /dev/null + zip "install.dat" * --recurse-paths --quiet + mv install.dat ../ + popd > /dev/null + + rm -rf "$folderName/internal/$build/bundle" + done + + # zip installer + echo "packaging installer..." + zip -9 "$folderName.zip" "$folderName" --recurse-paths --quiet + + # move zip back to Windows bin path + echo "moving release zip to $windowsBinPath/$folderName.zip..." + mv "$folderName.zip" "$windowsBinPath" + rm -rf "$folderName" + + echo "" + echo "" +done + +echo "Done!" diff --git a/build/windows/lib/in-place-regex.ps1 b/build/windows/lib/in-place-regex.ps1 new file mode 100644 index 00000000..7b309342 --- /dev/null +++ b/build/windows/lib/in-place-regex.ps1 @@ -0,0 +1,11 @@ +function In-Place-Regex { + param ( + [Parameter(Mandatory)][string]$Path, + [Parameter(Mandatory)][string]$Search, + [Parameter(Mandatory)][string]$Replace + ) + + $content = (Get-Content "$Path" -Encoding UTF8) + $content = ($content -replace "$Search", "$Replace") + [System.IO.File]::WriteAllLines((Get-Item "$Path").FullName, $content) +} diff --git a/build/windows/prepare-install-package.ps1 b/build/windows/prepare-install-package.ps1 new file mode 100644 index 00000000..db7fadcb --- /dev/null +++ b/build/windows/prepare-install-package.ps1 @@ -0,0 +1,217 @@ +# +# +# This is the PowerShell equivalent of ../unix/prepare-install-package.sh, *except* that it doesn't +# set Linux permissions, create the install.dat files, or create the final zip. Due to limitations +# in PowerShell, the final changes are handled by the windows/finalize-install-package.sh file in +# WSL. +# +# When making changes, make sure to update ../unix/prepare-install-package.ps1 too. +# +# + + +. "$PSScriptRoot\lib\in-place-regex.ps1" + +########## +## Constants +########## +# paths +$gamePath = "C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley" +$bundleModNames = "ConsoleCommands", "ErrorHandler", "SaveBackup" + +# build configuration +$buildConfig = "Release" +$folders = "linux", "macOS", "windows" +$runtimes = @{ linux = "linux-x64"; macOS = "osx-x64"; windows = "win-x64" } +$msBuildPlatformNames = @{ linux = "Unix"; macOS = "OSX"; windows = "Windows_NT" } + + +########## +## Move to SMAPI root +########## +cd "$PSScriptRoot/../.." + + +########## +## Clear old build files +########## +echo "Clearing old builds..." +echo "-------------------------------------------------" + +foreach ($path in (dir -Recurse -Include ('bin', 'obj'))) { + echo "$path" + rm -Recurse -Force "$path" +} +echo "" + + +########## +## Compile files +########## +ForEach ($folder in $folders) { + $runtime = $runtimes[$folder] + $msbuildPlatformName = $msBuildPlatformNames[$folder] + + 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" --self-contained true + echo "" + echo "" + + 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" -p:PublishTrimmed=True -p:TrimMode=Link --self-contained true + echo "" + echo "" + + foreach ($modName in $bundleModNames) { + echo "Compiling $modName for $folder..." + echo "-------------------------------------------------" + dotnet publish src/SMAPI.Mods.$modName --configuration $buildConfig -v minimal --runtime "$runtime" -p:OS="$msbuildPlatformName" -p:GamePath="$gamePath" -p:CopyToGameFolder="false" + echo "" + echo "" + } +} + + +########## +## Prepare install package +########## +echo "Preparing install package..." +echo "----------------------------" + +# init paths +$installAssets = "src/SMAPI.Installer/assets" +$packagePath = "bin/SMAPI installer" +$packageDevPath = "bin/SMAPI installer for developers" + +# init structure +foreach ($folder in $folders) { + mkdir "$packagePath/internal/$folder/bundle/smapi-internal" > $null +} + +# copy base installer files +foreach ($name in @("install on Linux.sh", "install on macOS.command", "install on Windows.bat", "README.txt")) { + cp "$installAssets/$name" "$packagePath" +} + +# copy per-platform files +foreach ($folder in $folders) { + $runtime = $runtimes[$folder] + + # get paths + $smapiBin = "src/SMAPI/bin/$buildConfig/$runtime/publish" + $internalPath = "$packagePath/internal/$folder" + $bundlePath = "$internalPath/bundle" + + # installer files + cp "src/SMAPI.Installer/bin/$buildConfig/$runtime/publish/*" "$internalPath" -Recurse + rm -Recurse -Force "$internalPath/assets" + + # runtime config for SMAPI + # 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 -eq "windows") { + cp "$installAssets/windows-exe-config.xml" "$packagePath/internal/windows/install.exe.config" + } + + # bundle root files + foreach ($name in @("StardewModdingAPI", "StardewModdingAPI.dll", "StardewModdingAPI.pdb", "StardewModdingAPI.xml", "steam_appid.txt")) { + if ($name -eq "StardewModdingAPI" -and $folder -eq "windows") { + $name = "$name.exe" + } + + cp "$smapiBin/$name" "$bundlePath" + } + + # bundle i18n + cp -Recurse "$smapiBin/i18n" "$bundlePath/smapi-internal" + + # bundle smapi-internal + foreach ($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")) { + cp "$smapiBin/$name" "$bundlePath/smapi-internal" + } + + cp "$smapiBin/SMAPI.config.json" "$bundlePath/smapi-internal/config.json" + cp "$smapiBin/SMAPI.metadata.json" "$bundlePath/smapi-internal/metadata.json" + if ($folder -eq "linux" -or $folder -eq "macOS") { + 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" + } + + # copy .NET dependencies + 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 -eq "windows") { + cp "$smapiBin/System.Management.dll" "$bundlePath/smapi-internal" + } + + # copy bundled mods + foreach ($modName in $bundleModNames) { + $fromPath = "src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime/publish" + $targetPath = "$bundlePath/Mods/$modName" + + mkdir "$targetPath" > $null + + cp "$fromPath/$modName.dll" "$targetPath" + cp "$fromPath/$modName.pdb" "$targetPath" + cp "$fromPath/manifest.json" "$targetPath" + if (Test-Path "$fromPath/i18n" -PathType Container) { + cp -Recurse "$fromPath/i18n" "$targetPath" + } + } +} + +# DISABLED: will be handled by Linux script +# mark scripts executable +#ForEach ($path in @("install on Linux.sh", "install on macOS.command", "bundle/unix-launcher.sh")) { +# if (Test-Path "$packagePath/$path" -PathType Leaf) { +# chmod 755 "$packagePath/$path" +# } +#} + +# split into main + for-dev folders +cp -Recurse "$packagePath" "$packageDevPath" +foreach ($folder in $folders) { + # disable developer mode in main package + In-Place-Regex -Path "$packagePath/internal/$folder/bundle/smapi-internal/config.json" -Search "`"DeveloperMode`": true" -Replace "`"DeveloperMode`": false" + + # DISABLED: will be handled by Linux script + # convert bundle folder into final 'install.dat' files + #foreach ($path in @("$packagePath/internal/$folder", "$packageDevPath/internal/$folder")) + #{ + # Compress-Archive -Path "$path/bundle/*" -CompressionLevel Optimal -DestinationPath "$path/install.zip" + # mv "$path/install.zip" "$path/install.dat" + # rm -Recurse -Force "$path/bundle" + #} +} + + +########### +### Create release zips +########### +# get version number +$version = $args[0] +if (!$version) { + $version = Read-Host "SMAPI release version (like '4.0.0')" +} + +# rename folders +mv "$packagePath" "bin/SMAPI $version installer" +mv "$packageDevPath" "bin/SMAPI $version installer for developers" + +# DISABLED: will be handled by Linux script +## package files +#Compress-Archive -Path "bin/SMAPI $version installer" -DestinationPath "bin/SMAPI $version installer.zip" -CompressionLevel Optimal +#Compress-Archive -Path "bin/SMAPI $version installer for developers" -DestinationPath "bin/SMAPI $version installer for developers.zip" -CompressionLevel Optimal + +echo "" +echo "Done! See docs/technical/smapi.md to create the release zips." diff --git a/build/windows/set-smapi-version.ps1 b/build/windows/set-smapi-version.ps1 new file mode 100644 index 00000000..ff6b2096 --- /dev/null +++ b/build/windows/set-smapi-version.ps1 @@ -0,0 +1,25 @@ +# +# +# This is the PowerShell equivalent of ../unix/set-smapi-version.sh. +# When making changes, both scripts should be updated. +# +# + + +. "$PSScriptRoot\lib\in-place-regex.ps1" + +# get version number +$version=$args[0] +if (!$version) { + $version = Read-Host "SMAPI release version (like '4.0.0')" +} + +# move to SMAPI root +cd "$PSScriptRoot/../.." + +# apply changes +In-Place-Regex -Path "build/common.targets" -Search ".+" -Replace "$version" +In-Place-Regex -Path "src/SMAPI/Constants.cs" -Search "RawApiVersion = `".+?`";" -Replace "RawApiVersion = `"$version`";" +ForEach ($modName in "ConsoleCommands","ErrorHandler","SaveBackup") { + In-Place-Regex -Path "src/SMAPI.Mods.$modName/manifest.json" -Search "`"(Version|MinimumApiVersion)`": `".+?`"" -Replace "`"`$1`": `"$version`"" +} -- 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build') 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 $(