summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig3
-rw-r--r--.gitattributes5
-rw-r--r--build/common.targets20
-rw-r--r--build/prepare-install-package.targets130
-rw-r--r--build/unix/prepare-install-package.sh211
-rw-r--r--build/unix/set-smapi-version.sh26
-rwxr-xr-xbuild/windows/finalize-install-package.sh67
-rw-r--r--build/windows/lib/in-place-regex.ps111
-rw-r--r--build/windows/prepare-install-package.ps1217
-rw-r--r--build/windows/set-smapi-version.ps125
-rw-r--r--docs/release-notes.md20
-rw-r--r--docs/technical/mod-package.md4
-rw-r--r--docs/technical/smapi.md156
-rw-r--r--src/SMAPI.Installer/Framework/InstallerContext.cs7
-rw-r--r--src/SMAPI.Installer/InteractiveInstaller.cs63
-rw-r--r--src/SMAPI.Installer/SMAPI.Installer.csproj1
-rw-r--r--src/SMAPI.Installer/assets/README.txt18
-rw-r--r--src/SMAPI.Installer/assets/install on Linux.sh4
-rw-r--r--src/SMAPI.Installer/assets/install on Windows.bat (renamed from src/SMAPI.Installer/assets/windows-install.bat)37
-rw-r--r--src/SMAPI.Installer/assets/install on macOS.command6
-rw-r--r--src/SMAPI.Installer/assets/runtimeconfig.json (renamed from src/SMAPI.Installer/assets/runtimeconfig.unix.json)6
-rw-r--r--src/SMAPI.Installer/assets/runtimeconfig.windows.json12
-rw-r--r--src/SMAPI.Installer/assets/unix-install.sh14
-rw-r--r--src/SMAPI.Installer/assets/unix-launcher.sh9
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/NetFieldAnalyzer.cs2
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/manifest.json4
-rw-r--r--src/SMAPI.Mods.ErrorHandler/i18n/pl.json8
-rw-r--r--src/SMAPI.Mods.ErrorHandler/manifest.json4
-rw-r--r--src/SMAPI.Mods.SaveBackup/manifest.json4
-rw-r--r--src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs21
-rw-r--r--src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs55
-rw-r--r--src/SMAPI.Web/wwwroot/SMAPI.metadata.json5
-rw-r--r--src/SMAPI.Web/wwwroot/schemas/content-patcher.json6
-rw-r--r--src/SMAPI.sln26
-rw-r--r--src/SMAPI/Constants.cs2
-rw-r--r--src/SMAPI/Framework/ModLoading/RewriteFacades/AccessToolsFacade.cs2
-rw-r--r--src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceFacade.cs2
-rw-r--r--src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyMethodFacade.cs2
-rw-r--r--src/SMAPI/Framework/ModLoading/RewriteFacades/SpriteBatchFacade.cs3
-rw-r--r--src/SMAPI/Framework/SGame.cs8
-rw-r--r--src/SMAPI/SButton.cs2
-rw-r--r--src/SMAPI/SMAPI.csproj3
-rw-r--r--src/SMAPI/Utilities/Keybind.cs2
-rw-r--r--src/SMAPI/i18n/pl.json12
44 files changed, 924 insertions, 321 deletions
diff --git a/.editorconfig b/.editorconfig
index d600d602..2aeaeadd 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -22,6 +22,9 @@ insert_final_newline = false
[README.txt]
end_of_line=crlf
+[*.{command,sh}]
+end_of_line=lf
+
##########
## C# formatting
## documentation: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
diff --git a/.gitattributes b/.gitattributes
index 1161a204..00ae145b 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,6 @@
# normalize line endings
* text=auto
-README.txt text=crlf
+README.txt text eol=crlf
+
+*.command text eol=lf
+*.sh text eol=lf
diff --git a/build/common.targets b/build/common.targets
index 578076a9..1021c2a1 100644
--- a/build/common.targets
+++ b/build/common.targets
@@ -1,13 +1,29 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--set general build properties -->
- <Version>3.13.1</Version>
+ <Version>3.13.2</Version>
<Product>SMAPI</Product>
<LangVersion>latest</LangVersion>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
<!--set platform-->
<DefineConstants Condition="$(OS) == 'Windows_NT'">$(DefineConstants);SMAPI_FOR_WINDOWS</DefineConstants>
+ <CopyToGameFolder>true</CopyToGameFolder>
+
+ <!-- allow mods to be compiled as AnyCPU for compatibility with older platforms -->
+ <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
+
+ <!--
+ suppress warnings that don't apply, so it's easier to spot actual issues.
+
+ warning | builds | summary | rationale
+ ┄┄┄┄┄┄┄ | ┄┄┄┄┄┄┄ | ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ | ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
+ CS0436 | all | local type conflicts with imported type | SMAPI needs to use certain low-level code during very early compatibility checks, before it's safe to load any other DLLs.
+ CA1416 | all | platform code available on all platforms | Compiler doesn't recognize the #if constants used by SMAPI.
+ CS0809 | all | obsolete overload for non-onsolete member | This is deliberate to signal to mods that certain APIs are only implemented for the game and shouldn't be called by mods.
+ NU1701 | all | NuGet package targets older .NET version | All such packages are carefully tested to make sure they do work.
+ -->
+ <NoWarn>$(NoWarn);CS0436;CA1416;CS0809;NU1701</NoWarn>
</PropertyGroup>
<!--find game folder-->
@@ -19,7 +35,7 @@
</Target>
<!-- copy files into game directory and enable debugging -->
- <Target Name="CopySmapiFiles" AfterTargets="AfterBuild">
+ <Target Name="CopySmapiFiles" AfterTargets="AfterBuild" Condition="'$(CopyToGameFolder)' == 'true'">
<CallTarget Targets="CopySMAPI;CopyDefaultMods" />
</Target>
<Target Name="CopySMAPI" Condition="'$(MSBuildProjectName)' == 'SMAPI'">
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 @@
-<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <!--
-
- This build task is run from the installer project after all projects have been compiled, and
- creates the build package in the bin\Packages folder.
-
- -->
- <Target Name="PrepareInstaller" AfterTargets="AfterBuild">
- <PropertyGroup>
- <PlatformName>windows</PlatformName>
- <PlatformName Condition="$(OS) != 'Windows_NT'">unix</PlatformName>
-
- <BuildRootPath>$(SolutionDir)</BuildRootPath>
- <OutRootPath>$(SolutionDir)\..\bin</OutRootPath>
-
- <SmapiBin>$(BuildRootPath)\SMAPI\bin\$(Configuration)</SmapiBin>
- <ToolkitBin>$(BuildRootPath)\SMAPI.Toolkit\bin\$(Configuration)\net5.0</ToolkitBin>
- <ConsoleCommandsBin>$(BuildRootPath)\SMAPI.Mods.ConsoleCommands\bin\$(Configuration)</ConsoleCommandsBin>
- <ErrorHandlerBin>$(BuildRootPath)\SMAPI.Mods.ErrorHandler\bin\$(Configuration)</ErrorHandlerBin>
- <SaveBackupBin>$(BuildRootPath)\SMAPI.Mods.SaveBackup\bin\$(Configuration)</SaveBackupBin>
-
- <PackagePath>$(OutRootPath)\SMAPI installer</PackagePath>
- <PackageDevPath>$(OutRootPath)\SMAPI installer for developers</PackageDevPath>
- </PropertyGroup>
- <ItemGroup>
- <TranslationFiles Include="$(SmapiBin)\i18n\*.json" />
- <ErrorHandlerTranslationFiles Include="$(ErrorHandlerBin)\i18n\*.json" />
- </ItemGroup>
-
- <!-- reset package directory -->
- <RemoveDir Directories="$(PackagePath)" />
- <RemoveDir Directories="$(PackageDevPath)" />
-
- <!-- copy installer files -->
- <Copy SourceFiles="$(TargetDir)\assets\unix-install.sh" DestinationFiles="$(PackagePath)\install on Linux.sh" />
- <Copy SourceFiles="$(TargetDir)\assets\unix-install.sh" DestinationFiles="$(PackagePath)\install on macOS.command" />
- <Copy SourceFiles="$(TargetDir)\assets\windows-install.bat" DestinationFiles="$(PackagePath)\install on Windows.bat" />
- <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).runtimeconfig.json" DestinationFolder="$(PackagePath)\internal\$(PlatformName)" />
-
- <!--copy bundle files-->
- <Copy SourceFiles="$(TargetDir)\assets\runtimeconfig.$(PlatformName).json" DestinationFiles="$(PackagePath)\bundle\StardewModdingAPI.runtimeconfig.json" />
- <Copy SourceFiles="$(SmapiBin)\StardewModdingAPI.dll" DestinationFolder="$(PackagePath)\bundle" />
- <Copy SourceFiles="$(SmapiBin)\StardewModdingAPI.exe" DestinationFolder="$(PackagePath)\bundle" Condition="$(PlatformName) == 'windows'" />
- <Copy SourceFiles="$(SmapiBin)\StardewModdingAPI" DestinationFolder="$(PackagePath)\bundle" Condition="$(PlatformName) != 'windows'" />
- <Copy SourceFiles="$(SmapiBin)\StardewModdingAPI.pdb" DestinationFolder="$(PackagePath)\bundle" />
- <Copy SourceFiles="$(SmapiBin)\StardewModdingAPI.xml" DestinationFolder="$(PackagePath)\bundle" />
- <Copy SourceFiles="$(SmapiBin)\steam_appid.txt" DestinationFolder="$(PackagePath)\bundle" />
- <Copy SourceFiles="$(SmapiBin)\0Harmony.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\0Harmony.xml" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\Mono.Cecil.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\Mono.Cecil.Mdb.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\Mono.Cecil.Pdb.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\MonoMod.Common.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\Newtonsoft.Json.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\TMXTile.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\SMAPI.config.json" DestinationFiles="$(PackagePath)\bundle\smapi-internal\config.json" />
- <Copy SourceFiles="$(SmapiBin)\SMAPI.metadata.json" DestinationFiles="$(PackagePath)\bundle\smapi-internal\metadata.json" />
- <Copy SourceFiles="$(ToolkitBin)\SMAPI.Toolkit.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(ToolkitBin)\SMAPI.Toolkit.pdb" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(ToolkitBin)\SMAPI.Toolkit.xml" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(ToolkitBin)\SMAPI.Toolkit.CoreInterfaces.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(ToolkitBin)\SMAPI.Toolkit.CoreInterfaces.pdb" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(ToolkitBin)\SMAPI.Toolkit.CoreInterfaces.xml" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="@(TranslationFiles)" DestinationFolder="$(PackagePath)\bundle\smapi-internal\i18n" />
- <Copy Condition="$(PlatformName) == 'unix'" SourceFiles="$(TargetDir)\assets\unix-launcher.sh" DestinationFolder="$(PackagePath)\bundle" />
- <Copy Condition="$(PlatformName) == 'unix'" SourceFiles="$(SmapiBin)\System.Runtime.Caching.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy Condition="$(PlatformName) == 'windows'" SourceFiles="$(TargetDir)\assets\windows-exe-config.xml" DestinationFiles="$(PackagePath)\bundle\StardewModdingAPI.exe.config" />
-
- <!-- copy .NET dependencies -->
- <Copy SourceFiles="$(SmapiBin)\System.Configuration.ConfigurationManager.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\System.Management.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" Condition="$(PlatformName) == 'windows'" />
- <Copy SourceFiles="$(SmapiBin)\System.Runtime.Caching.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <Copy SourceFiles="$(SmapiBin)\System.Security.Permissions.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
-
- <!--copy bundled mods-->
- <Copy SourceFiles="$(ConsoleCommandsBin)\ConsoleCommands.dll" DestinationFolder="$(PackagePath)\bundle\Mods\ConsoleCommands" />
- <Copy SourceFiles="$(ConsoleCommandsBin)\ConsoleCommands.pdb" DestinationFolder="$(PackagePath)\bundle\Mods\ConsoleCommands" />
- <Copy SourceFiles="$(ConsoleCommandsBin)\manifest.json" DestinationFolder="$(PackagePath)\bundle\Mods\ConsoleCommands" />
- <Copy SourceFiles="$(ErrorHandlerBin)\ErrorHandler.dll" DestinationFolder="$(PackagePath)\bundle\Mods\ErrorHandler" />
- <Copy SourceFiles="$(ErrorHandlerBin)\ErrorHandler.pdb" DestinationFolder="$(PackagePath)\bundle\Mods\ErrorHandler" />
- <Copy SourceFiles="$(ErrorHandlerBin)\manifest.json" DestinationFolder="$(PackagePath)\bundle\Mods\ErrorHandler" />
- <Copy SourceFiles="@(ErrorHandlerTranslationFiles)" DestinationFolder="$(PackagePath)\bundle\Mods\ErrorHandler\i18n" />
- <Copy SourceFiles="$(SaveBackupBin)\SaveBackup.dll" DestinationFolder="$(PackagePath)\bundle\Mods\SaveBackup" />
- <Copy SourceFiles="$(SaveBackupBin)\SaveBackup.pdb" DestinationFolder="$(PackagePath)\bundle\Mods\SaveBackup" />
- <Copy SourceFiles="$(SaveBackupBin)\manifest.json" DestinationFolder="$(PackagePath)\bundle\Mods\SaveBackup" />
-
- <!-- fix Linux/macOS permissions -->
- <Exec Condition="$(PlatformName) == 'unix'" Command="chmod 755 &quot;$(PackagePath)/install on Linux.sh&quot;" />
- <Exec Condition="$(PlatformName) == 'unix'" Command="chmod 755 &quot;$(PackagePath)/install on macOS.command&quot;" />
- <Exec Condition="$(PlatformName) == 'unix'" Command="chmod 755 &quot;$(PackagePath)/bundle/unix-launcher.sh&quot;" />
-
- <!-- finalise 'for developers' installer -->
- <ItemGroup>
- <PackageFiles Include="$(PackagePath)\**\*.*" />
- </ItemGroup>
- <Copy SourceFiles="@(PackageFiles)" DestinationFolder="$(PackageDevPath)\%(RecursiveDir)" />
- <ZipDirectory SourceDirectory="$(PackageDevPath)\bundle" DestinationFile="$(PackageDevPath)\internal\$(PlatformName)\install.dat" />
- <RemoveDir Directories="$(PackageDevPath)\bundle" />
-
- <!-- finalise normal installer -->
- <ReplaceFileText FilePath="$(PackagePath)\bundle\smapi-internal\config.json" Search="&quot;DeveloperMode&quot;: true" Replace="&quot;DeveloperMode&quot;: false" />
- <ZipDirectory SourceDirectory="$(PackagePath)\bundle" DestinationFile="$(PackagePath)\internal\$(PlatformName)\install.dat" />
- <RemoveDir Directories="$(PackagePath)\bundle" />
- </Target>
-
- <!-- Replace text in a file based on a regex pattern. Derived from https://stackoverflow.com/a/22571621/262123. -->
- <UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
- <ParameterGroup>
- <FilePath ParameterType="System.String" Required="true" />
- <Search ParameterType="System.String" Required="true" />
- <Replace ParameterType="System.String" Required="true" />
- </ParameterGroup>
- <Task>
- <Using Namespace="System" />
- <Using Namespace="System.IO" />
- <Using Namespace="System.Text.RegularExpressions" />
- <Code Type="Fragment" Language="cs">
- <![CDATA[
- File.WriteAllText(
- FilePath,
- Regex.Replace(File.ReadAllText(FilePath), Search, Replace)
- );
- ]]>
- </Code>
- </Task>
- </UsingTask>
-</Project>
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>$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 @@
+#
+