2017-02-04 09:18:00 +08:00
|
|
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<!--
|
2020-01-10 08:27:56 +08:00
|
|
|
|
2017-02-04 09:18:00 +08:00
|
|
|
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.
|
2020-01-10 08:27:56 +08:00
|
|
|
|
2017-02-04 09:18:00 +08:00
|
|
|
-->
|
2019-09-14 05:22:45 +08:00
|
|
|
<Target Name="PrepareInstaller" AfterTargets="AfterBuild">
|
2017-02-04 09:18:00 +08:00
|
|
|
<PropertyGroup>
|
2018-11-20 02:37:46 +08:00
|
|
|
<PlatformName>windows</PlatformName>
|
|
|
|
<PlatformName Condition="$(OS) != 'Windows_NT'">unix</PlatformName>
|
2020-02-01 11:27:12 +08:00
|
|
|
|
|
|
|
<BuildRootPath>$(SolutionDir)</BuildRootPath>
|
|
|
|
<OutRootPath>$(SolutionDir)\..\bin</OutRootPath>
|
|
|
|
|
|
|
|
<SmapiBin>$(BuildRootPath)\SMAPI\bin\$(Configuration)</SmapiBin>
|
|
|
|
<ToolkitBin>$(BuildRootPath)\SMAPI.Toolkit\bin\$(Configuration)\net4.5</ToolkitBin>
|
|
|
|
<ConsoleCommandsBin>$(BuildRootPath)\SMAPI.Mods.ConsoleCommands\bin\$(Configuration)</ConsoleCommandsBin>
|
2021-01-16 07:48:29 +08:00
|
|
|
<ErrorHandlerBin>$(BuildRootPath)\SMAPI.Mods.ErrorHandler\bin\$(Configuration)</ErrorHandlerBin>
|
2020-02-01 11:27:12 +08:00
|
|
|
<SaveBackupBin>$(BuildRootPath)\SMAPI.Mods.SaveBackup\bin\$(Configuration)</SaveBackupBin>
|
|
|
|
|
|
|
|
<PackagePath>$(OutRootPath)\SMAPI installer</PackagePath>
|
|
|
|
<PackageDevPath>$(OutRootPath)\SMAPI installer for developers</PackageDevPath>
|
2017-02-04 09:18:00 +08:00
|
|
|
</PropertyGroup>
|
2019-10-02 09:27:49 +08:00
|
|
|
<ItemGroup>
|
2020-02-01 11:27:12 +08:00
|
|
|
<TranslationFiles Include="$(SmapiBin)\i18n\*.json" />
|
2021-01-16 07:48:29 +08:00
|
|
|
<ErrorHandlerTranslationFiles Include="$(ErrorHandlerBin)\i18n\*.json" />
|
2019-10-02 09:27:49 +08:00
|
|
|
</ItemGroup>
|
2018-08-31 06:14:40 +08:00
|
|
|
|
2017-02-04 09:18:00 +08:00
|
|
|
<!-- reset package directory -->
|
2017-02-04 11:02:54 +08:00
|
|
|
<RemoveDir Directories="$(PackagePath)" />
|
2018-11-18 13:51:30 +08:00
|
|
|
<RemoveDir Directories="$(PackageDevPath)" />
|
2020-01-10 08:27:56 +08:00
|
|
|
|
2017-02-04 09:18:00 +08:00
|
|
|
<!-- copy installer files -->
|
2020-02-01 11:27:12 +08:00
|
|
|
<Copy SourceFiles="$(TargetDir)\assets\unix-install.sh" DestinationFiles="$(PackagePath)\install on Linux.sh" />
|
2021-04-04 23:37:11 +08:00
|
|
|
<Copy SourceFiles="$(TargetDir)\assets\unix-install.sh" DestinationFiles="$(PackagePath)\install on macOS.command" />
|
2020-02-01 11:27:12 +08:00
|
|
|
<Copy SourceFiles="$(TargetDir)\assets\windows-install.bat" DestinationFiles="$(PackagePath)\install on Windows.bat" />
|
|
|
|
<Copy SourceFiles="$(TargetDir)\assets\README.txt" DestinationFiles="$(PackagePath)\README.txt" />
|
2018-11-20 02:37:46 +08:00
|
|
|
<Copy SourceFiles="$(TargetDir)\$(TargetName).exe" DestinationFiles="$(PackagePath)\internal\$(PlatformName)-install.exe" />
|
2020-02-01 11:27:12 +08:00
|
|
|
<Copy Condition="$(PlatformName) == 'windows'" SourceFiles="$(TargetDir)\assets\windows-exe-config.xml" DestinationFiles="$(PackagePath)\internal\$(PlatformName)-install.exe.config" />
|
2017-05-04 00:28:05 +08:00
|
|
|
|
2018-11-18 13:47:35 +08:00
|
|
|
<!--copy bundle files-->
|
2020-02-01 11:27:12 +08:00
|
|
|
<Copy SourceFiles="$(SmapiBin)\StardewModdingAPI.exe" DestinationFolder="$(PackagePath)\bundle" />
|
|
|
|
<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" />
|
2021-07-13 21:14:07 +08:00
|
|
|
<Copy SourceFiles="$(SmapiBin)\0Harmony.xml" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
|
2020-02-01 11:27:12 +08:00
|
|
|
<Copy SourceFiles="$(SmapiBin)\Mono.Cecil.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
|
2021-07-24 08:29:44 +08:00
|
|
|
<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" />
|
2020-02-01 11:27:12 +08:00
|
|
|
<Copy SourceFiles="$(SmapiBin)\Newtonsoft.Json.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
|
2020-02-01 13:27:53 +08:00
|
|
|
<Copy SourceFiles="$(SmapiBin)\TMXTile.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
|
2020-02-01 11:27:12 +08:00
|
|
|
<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" />
|
2019-10-02 09:27:49 +08:00
|
|
|
<Copy SourceFiles="@(TranslationFiles)" DestinationFolder="$(PackagePath)\bundle\smapi-internal\i18n" />
|
2020-02-01 11:27:12 +08:00
|
|
|
<Copy Condition="$(PlatformName) == 'unix'" SourceFiles="$(TargetDir)\assets\unix-launcher.sh" DestinationFiles="$(PackagePath)\bundle\StardewModdingAPI" />
|
|
|
|
<Copy Condition="$(PlatformName) == 'unix'" SourceFiles="$(SmapiBin)\System.Numerics.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
|
|
|
|
<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" />
|
2018-08-20 06:28:16 +08:00
|
|
|
|
2019-09-14 05:22:45 +08:00
|
|
|
<!--copy bundled mods-->
|
2020-02-01 11:27:12 +08:00
|
|
|
<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" />
|
2021-01-16 07:48:29 +08:00
|
|
|
<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" />
|
2020-02-01 11:27:12 +08:00
|
|
|
<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" />
|
2019-09-14 05:22:45 +08:00
|
|
|
|
2021-04-04 23:37:11 +08:00
|
|
|
<!-- fix errors on Linux/macOS (sample: https://smapi.io/log/mMdFUpgB) -->
|
2020-02-01 11:27:12 +08:00
|
|
|
<Copy Condition="$(PlatformName) == 'unix'" SourceFiles="$(TargetDir)\assets\System.Numerics.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
|
|
|
|
<Copy Condition="$(PlatformName) == 'unix'" SourceFiles="$(TargetDir)\assets\System.Runtime.Caching.dll" DestinationFolder="$(PackagePath)\bundle\smapi-internal" />
|
2018-11-20 04:05:44 +08:00
|
|
|
|
2021-04-04 23:37:11 +08:00
|
|
|
<!-- fix Linux/macOS permissions -->
|
2020-02-01 11:27:12 +08:00
|
|
|
<Exec Condition="$(PlatformName) == 'unix'" Command="chmod 755 "$(PackagePath)\install on Linux.sh"" />
|
2021-04-04 23:37:11 +08:00
|
|
|
<Exec Condition="$(PlatformName) == 'unix'" Command="chmod 755 "$(PackagePath)\install on macOS.command"" />
|
2018-11-18 13:51:30 +08:00
|
|
|
|
|
|
|
<!-- finalise 'for developers' installer -->
|
|
|
|
<ItemGroup>
|
|
|
|
<PackageFiles Include="$(PackagePath)\**\*.*" />
|
|
|
|
</ItemGroup>
|
|
|
|
<Copy SourceFiles="@(PackageFiles)" DestinationFolder="$(PackageDevPath)\%(RecursiveDir)" />
|
2018-11-20 02:37:46 +08:00
|
|
|
<ZipDirectory FromDirPath="$(PackageDevPath)\bundle" ToFilePath="$(PackageDevPath)\internal\$(PlatformName)-install.dat" />
|
2018-11-18 13:51:30 +08:00
|
|
|
<RemoveDir Directories="$(PackageDevPath)\bundle" />
|
|
|
|
|
|
|
|
<!-- finalise normal installer -->
|
2019-04-25 11:46:52 +08:00
|
|
|
<ReplaceFileText FilePath="$(PackagePath)\bundle\smapi-internal\config.json" Search=""DeveloperMode": true" Replace=""DeveloperMode": false" />
|
2018-11-20 02:37:46 +08:00
|
|
|
<ZipDirectory FromDirPath="$(PackagePath)\bundle" ToFilePath="$(PackagePath)\internal\$(PlatformName)-install.dat" />
|
2018-11-18 13:47:35 +08:00
|
|
|
<RemoveDir Directories="$(PackagePath)\bundle" />
|
2017-02-04 09:18:00 +08:00
|
|
|
</Target>
|
2018-11-18 13:47:35 +08:00
|
|
|
|
2018-11-18 13:51:30 +08:00
|
|
|
<!-- Create a zip file with the contents of a given folder path. Derived from https://stackoverflow.com/a/38127938/262123. -->
|
2018-11-18 13:47:35 +08:00
|
|
|
<UsingTask TaskName="ZipDirectory" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
|
|
|
|
<ParameterGroup>
|
|
|
|
<FromDirPath ParameterType="System.String" Required="true" />
|
|
|
|
<ToFilePath ParameterType="System.String" Required="true" />
|
|
|
|
</ParameterGroup>
|
|
|
|
<Task>
|
|
|
|
<Reference Include="System.IO.Compression.FileSystem" />
|
|
|
|
<Using Namespace="System.IO.Compression" />
|
|
|
|
<Code Type="Fragment" Language="cs">
|
|
|
|
<![CDATA[
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ZipFile.CreateFromDirectory(FromDirPath, ToFilePath);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch(Exception ex)
|
|
|
|
{
|
|
|
|
Log.LogErrorFromException(ex);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</Code>
|
|
|
|
</Task>
|
|
|
|
</UsingTask>
|
2018-11-18 13:51:30 +08:00
|
|
|
|
|
|
|
<!-- 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>
|
2017-02-04 11:02:54 +08:00
|
|
|
</Project>
|