Download CoreLoad on Install

This commit is contained in:
Mino 2020-03-30 18:18:28 +09:00
parent 693babc1e3
commit 67f4795cf6
3 changed files with 50 additions and 16 deletions

2
.gitignore vendored
View file

@ -332,3 +332,5 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
/lib/*

View file

@ -1,16 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nuke.Common" Version="0.24.4" />
<PackageDownload Include="GitVersion.Tool" Version="[5.1.1]" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nuke.Common" Version="0.24.4" />
<PackageDownload Include="GitVersion.Tool" Version="[5.1.1]" />
<PackageReference Include="Flurl" Version="2.8.2" />
<PackageReference Include="Flurl.Http" Version="2.4.2" />
</ItemGroup>
</Project>

View file

@ -1,6 +1,9 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using Flurl;
using Flurl.Http;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.Git;
@ -15,6 +18,7 @@ using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Nuke.Common.Logger;
using System.Threading.Tasks;
[CheckBuildProjectConfigurations]
[UnsetVisualStudioEnvironmentVariables]
@ -39,6 +43,8 @@ class DalamudBuild : NukeBuild
AbsolutePath DefaultInstallDirectory => (AbsolutePath)Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) / "Dalamud" / "bin" / GitVersion.SemVer;
AbsolutePath CoreHookBinaryDirectory => RootDirectory / "lib" / "CoreHookBinary";
Target Clean => _ => _
.Before(Restore)
.Executes(() =>
@ -66,11 +72,35 @@ class DalamudBuild : NukeBuild
.EnableNoRestore());
});
Target DownloadCoreHookBinary => _ => _
.Executes(() =>
{
// Download pre-compiled binary of CoreHook.Hooking and CoreLoad (these are prerequisite)
var corehookTask = ExtractZip($"https://github.com/unknownv2/CoreHook.Hooking/releases/download/1.0.9/corehook-{Configuration}-x64.zip", CoreHookBinaryDirectory);
var coreloadTask = ExtractZip($"https://github.com/unknownv2/CoreHook.Host/releases/download/2.0.5/coreload-{Configuration}-x64.zip", CoreHookBinaryDirectory);
Task.WaitAll(corehookTask, coreloadTask);
});
Target Install => _ => _
.DependsOn(DownloadCoreHookBinary) // prolly can be skipped if prerequisites are already there?
.DependsOn(Compile)
.Executes(() =>
{
Info($"Installing Dalamud to {DefaultInstallDirectory}");
// TODO
});
async Task ExtractZip(string uri, string directory)
{
EnsureExistingDirectory(directory);
Info($"Downloading {uri}");
var tempDir = Path.GetTempPath();
var zipFilePath = await uri.DownloadFileAsync(tempDir);
Info($"Extracting {zipFilePath}");
ZipFile.ExtractToDirectory(zipFilePath, directory);
}
}