summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/prepare-install-package.targets51
-rw-r--r--docs/technical-docs.md53
-rw-r--r--src/SMAPI.Installer/InteractiveInstaller.cs16
3 files changed, 72 insertions, 48 deletions
diff --git a/build/prepare-install-package.targets b/build/prepare-install-package.targets
index 127a8dd5..0b575d6f 100644
--- a/build/prepare-install-package.targets
+++ b/build/prepare-install-package.targets
@@ -10,9 +10,10 @@
<CompiledRootPath>$(SolutionDir)\..\bin\$(Configuration)</CompiledRootPath>
<CompiledSmapiPath>$(CompiledRootPath)\SMAPI</CompiledSmapiPath>
<CompiledToolkitPath>$(CompiledRootPath)\SMAPI.Toolkit\net4.5</CompiledToolkitPath>
- <PackagePath>$(SolutionDir)\..\bin\Packaged</PackagePath>
- <PackageBundleFilename>bundle.windows.zipped</PackageBundleFilename>
- <PackageBundleFilename Condition="$(OS) != 'Windows_NT'">bundle.mono.zipped</PackageBundleFilename>
+ <PackagePath>$(SolutionDir)\..\bin\SMAPI installer</PackagePath>
+ <PackageDevPath>$(SolutionDir)\..\bin\SMAPI installer for developers</PackageDevPath>
+ <PackageBundlePlatform>windows</PackageBundlePlatform>
+ <PackageBundlePlatform Condition="$(OS) != 'Windows_NT'">mono</PackageBundlePlatform>
</PropertyGroup>
<ItemGroup>
<CompiledMods Include="$(SolutionDir)\..\bin\$(Configuration)\Mods\**\*.*" />
@@ -20,6 +21,7 @@
<!-- reset package directory -->
<RemoveDir Directories="$(PackagePath)" />
+ <RemoveDir Directories="$(PackageDevPath)" />
<!-- copy installer files -->
<Copy SourceFiles="$(TargetDir)\unix-install.sh" DestinationFiles="$(PackagePath)\install on Linux.sh" />
@@ -27,7 +29,7 @@
<Copy SourceFiles="$(TargetDir)\windows-install.bat" DestinationFiles="$(PackagePath)\install on Windows.bat" />
<Copy SourceFiles="$(TargetDir)\README.txt" DestinationFiles="$(PackagePath)\README.txt" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).exe" DestinationFiles="$(PackagePath)\internal\install.exe" />
- <Copy Condition="$(OS) == 'Windows_NT'" SourceFiles="$(TargetDir)\windows-exe-config.xml" DestinationFiles="$(PackagePath)\internal\install.exe.config" />
+ <Copy SourceFiles="$(TargetDir)\windows-exe-config.xml" DestinationFiles="$(PackagePath)\internal\install.exe.config" />
<!--copy bundle files-->
<Copy SourceFiles="$(TargetDir)\unix-launcher.sh" DestinationFiles="$(PackagePath)\bundle\StardewModdingAPI" />
@@ -52,11 +54,25 @@
<Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\System.Numerics.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
<Copy Condition="$(OS) != 'Windows_NT'" SourceFiles="$(CompiledSmapiPath)\System.Runtime.Caching.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
- <!-- zip bundle files -->
- <ZipDirectory FromDirPath="$(PackagePath)\bundle" ToFilePath="$(PackagePath)\internal\$(PackageBundleFilename)" />
+ <!-- fix Linux/Mac permissions -->
+ <Exec Condition="$(OS) != 'Windows_NT'" Command="chmod 755 &quot;$(PackagePath)\install on Linux.sh&quot;" />
+ <Exec Condition="$(OS) != 'Windows_NT'" Command="chmod 755 &quot;$(PackagePath)\install on Mac.command&quot;" />
+
+ <!-- finalise 'for developers' installer -->
+ <ItemGroup>
+ <PackageFiles Include="$(PackagePath)\**\*.*" />
+ </ItemGroup>
+ <Copy SourceFiles="@(PackageFiles)" DestinationFolder="$(PackageDevPath)\%(RecursiveDir)" />
+ <ZipDirectory FromDirPath="$(PackageDevPath)\bundle" ToFilePath="$(PackageDevPath)\internal\bundle.$(PackageBundlePlatform).zipped" />
+ <RemoveDir Directories="$(PackageDevPath)\bundle" />
+
+ <!-- finalise normal installer -->
+ <ReplaceFileText FilePath="$(PackagePath)\bundle\smapi-internal\StardewModdingAPI.config.json" Search="&quot;DeveloperMode&quot;: true" Replace="&quot;DeveloperMode&quot;: false" />
+ <ZipDirectory FromDirPath="$(PackagePath)\bundle" ToFilePath="$(PackagePath)\internal\bundle.$(PackageBundlePlatform).zipped" />
<RemoveDir Directories="$(PackagePath)\bundle" />
</Target>
+ <!-- Create a zip file with the contents of a given folder path. Derived from https://stackoverflow.com/a/38127938/262123. -->
<UsingTask TaskName="ZipDirectory" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<FromDirPath ParameterType="System.String" Required="true" />
@@ -81,4 +97,27 @@
</Code>
</Task>
</UsingTask>
+
+ <!-- Replace text in a file based on a regex pattern. Derived from https://stackoverflow.com/a/22571621/262123. -->
+ <UsingTask TaskName="ReplaceFileText" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+ <ParameterGroup>
+ <FilePath ParameterType="System.String" Required="true" />
+ <Search ParameterType="System.String" Required="true" />
+ <Replace ParameterType="System.String" Required="true" />
+ </ParameterGroup>
+ <Task>
+ <Reference Include="System.Core" />
+ <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/docs/technical-docs.md b/docs/technical-docs.md
index 4a8f45f1..88c1a91f 100644
--- a/docs/technical-docs.md
+++ b/docs/technical-docs.md
@@ -44,7 +44,7 @@ executed. This doesn't work in MonoDevelop on Linux, unfortunately.
### Preparing a release
To prepare a crossplatform SMAPI release, you'll need to compile it on two platforms. See
-[crossplatforming info](https://stardewvalleywiki.com/Modding:Creating_a_SMAPI_mod#Test_on_all_platforms)
+[crossplatforming info](https://stardewvalleywiki.com/Modding:Modder_Guide/Test_and_Troubleshoot#Testing_on_all_platforms)
on the wiki for the first-time setup.
1. Update the version number in `GlobalAssemblyInfo.cs` and `Constants::Version`. Make sure you use a
@@ -57,47 +57,16 @@ on the wiki for the first-time setup.
release | `<version>` | `3.0`
2. In Windows:
- 1. Rebuild the solution in _Release_ mode.
- 2. Rename `bin/Packaged` to `SMAPI <version>` (e.g. `SMAPI 3.0`).
- 2. Transfer the `SMAPI <version>` folder to Linux or Mac.
- _This adds the installer executable and Windows files. We'll do the rest in Linux or Mac,
- since we need to set Unix file permissions that Windows won't save._
-
-2. In Linux or Mac:
- 1. Rebuild the solution in _Release_ mode.
- 2. Copy `bin/internal/Packaged/Mono` into the `SMAPI <version>` folder.
- 3. If you did everything right so far, you should have a folder like this:
-
- ```
- SMAPI 3.0 installer/
- install on Linux.sh
- install on Mac.command
- install on Windows.exe
- README.txt
- internal/
- Mono/
- Mods/*
- smapi-internal/*
- StardewModdingAPI
- StardewModdingAPI.exe
- StardewModdingAPI.pdb
- StardewModdingAPI.xml
- steam_appid.txt
- Windows/
- Mods/*
- smapi-internal/*
- StardewModdingAPI.exe
- StardewModdingAPI.pdb
- StardewModdingAPI.xml
- steam_appid.txt
- ```
- 4. Open a terminal in the `SMAPI <version>` folder and run `chmod 755 internal/Mono/StardewModdingAPI`.
- 5. Copy & paste the `SMAPI <version>` folder as `SMAPI <version> for developers`.
- 6. In the `SMAPI <version>` folder...
- * edit `internal/Mono/StardewModdingAPI.config.json` and
- `internal/Windows/StardewModdingAPI.config.json` to disable developer mode;
- * delete `internal/Windows/StardewModdingAPI.xml`.
- 7. Compress the two folders into `SMAPI <version>.zip` and `SMAPI <version> for developers.zip`.
+ 1. Rebuild the solution in Release mode.
+ 2. Copy `bundle.windows.zipped` from `bin/SMAPI installer` and `bin/SMAPI installer for developers`
+ to Linux/Mac.
+
+3. In Linux/Mac:
+ 1. Rebuild the solution in Release mode.
+ 2. Add the `bundle.windows.zipped` files to the `bin/SMAPI installer` and
+ `bin/SMAPI installer for developers` folders.
+ 3. Rename the folders to `SMAPI <version> installer` and `SMAPI <version> installer for developers`.
+ 4. Zip the two folders.
## Customisation
### Configuration file
diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs
index 4212418d..d5866c74 100644
--- a/src/SMAPI.Installer/InteractiveInstaller.cs
+++ b/src/SMAPI.Installer/InteractiveInstaller.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -445,6 +446,8 @@ namespace StardewModdingApi.Installer
if (platform.IsMono())
{
this.PrintDebug("Safely replacing game launcher...");
+
+ // back up & remove current launcher
if (File.Exists(paths.UnixLauncherPath))
{
if (!File.Exists(paths.UnixBackupLauncherPath))
@@ -453,7 +456,20 @@ namespace StardewModdingApi.Installer
this.InteractivelyDelete(paths.UnixLauncherPath);
}
+ // add new launcher
File.Move(paths.UnixSmapiLauncherPath, paths.UnixLauncherPath);
+
+ // mark file executable
+ // (MSBuild doesn't keep permission flags for files zipped in a build task.)
+ new Process
+ {
+ StartInfo = new ProcessStartInfo
+ {
+ FileName = "chmod",
+ Arguments = $"755 \"{paths.UnixLauncherPath}\"",
+ CreateNoWindow = true
+ }
+ }.Start();
}
// create mods directory (if needed)