Files
MaaAssistantArknights/tools/MaaBuilder/Build.Job.Bundle.cs
2022-07-12 05:42:19 +08:00

58 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using MaaBuilder.Models;
using Nuke.Common;
using Nuke.Common.IO;
namespace MaaBuilder;
public partial class Build
{
Target UseMaaDevBundle => _ => _
.DependsOn(WithCompileCoreRelease, WithCompileWpfRelease)
.Triggers(SetPackageBundled)
.Executes(() =>
{
var buildOutput = Parameters.BuildOutput / BuildConfiguration.Release;
BundlePackage(buildOutput, MaaDevBundlePackageName);
});
Target UseMaaRelease => _ => _
.DependsOn(WithCompileCoreRelease, WithCompileWpfRelease)
.Triggers(SetPackageBundled)
.Executes(() =>
{
var releaseBuildOutput = Parameters.BuildOutput / BuildConfiguration.Release;
RemoveDebugSymbols(releaseBuildOutput);
foreach (var package in Parameters.Packages)
{
var name = package.NameTemplate.Replace("{VERSION}", Version);
BundleMaaBundle(releaseBuildOutput, name, package);
}
});
Target SetPackageBundled => _ => _
.After(UseMaaDevBundle)
.Executes(() =>
{
Information("已完成打包");
var checksumFile = Parameters.ArtifactOutput / "checksum.txt";
var checksum = new List<string>();
foreach (var file in Parameters.ArtifactOutput.GlobFiles("*.zip"))
{
var size = (new FileInfo(file).Length / 1024.0 / 1024.0).ToString("F3");
var hash = FileSystemTasks.GetFileHash(file);
Information($"找到 Artifact ({hash}){file} ({size} MB)");
checksum.Add($"{file.Name}:{hash}");
}
File.WriteAllLines(checksumFile, checksum, Encoding.UTF8);
});
}