307 lines
8.5 KiB
Plaintext
307 lines
8.5 KiB
Plaintext
![]() |
#addin nuget:?package=Cake.Json&version=6.0.1
|
||
|
#addin nuget:?package=Newtonsoft.Json&version=11.0.2
|
||
|
|
||
|
using Path = System.IO.Path;
|
||
|
|
||
|
var target = Argument<string>("target", "Build");
|
||
|
|
||
|
var skipClean = HasArgument("skip-clean");
|
||
|
var skipBuild = !HasArgument("rebuild");
|
||
|
var preserveDevFolder = HasArgument("preserve");
|
||
|
|
||
|
var configPath = Argument<string>("config", "./build-config.json");
|
||
|
|
||
|
public class Config
|
||
|
{
|
||
|
public string LauncherCodePath { get; set; }
|
||
|
public string ModulesCodePath { get; set; }
|
||
|
public string ServerCodePath { get; set; }
|
||
|
public string DevGameFolder { get; set; }
|
||
|
}
|
||
|
|
||
|
var config = DeserializeJsonFromFile<Config>(configPath);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------------------
|
||
|
// Launcher
|
||
|
// ------------------------------------------------------------------
|
||
|
|
||
|
Task("Clean:Launcher")
|
||
|
.WithCriteria(!skipClean)
|
||
|
.Does(() =>
|
||
|
{
|
||
|
Information("Cleaning launcher build folder");
|
||
|
CleanDirectory(Path.Combine(config.LauncherCodePath, "project", "Build"));
|
||
|
|
||
|
Information("Cleaning launcher bin folders");
|
||
|
DotNetCoreClean(Path.Combine(config.LauncherCodePath, "project", "Launcher.sln"), new DotNetCoreCleanSettings
|
||
|
{
|
||
|
Configuration = "Release",
|
||
|
DiagnosticOutput = false,
|
||
|
NoLogo = true,
|
||
|
Verbosity = DotNetCoreVerbosity.Minimal
|
||
|
});
|
||
|
});
|
||
|
|
||
|
Task("Restore:Launcher")
|
||
|
.Does(() =>
|
||
|
{
|
||
|
DotNetCoreRestore(Path.Combine(config.LauncherCodePath, "project", "Launcher.sln"), new DotNetCoreRestoreSettings
|
||
|
{
|
||
|
Runtime = "win10-x64"
|
||
|
});
|
||
|
});
|
||
|
|
||
|
Task("Build:Launcher")
|
||
|
.IsDependentOn("Clean:Launcher")
|
||
|
.IsDependentOn("Restore:Launcher")
|
||
|
.Does(() =>
|
||
|
{
|
||
|
var projectPath = Path.Combine(config.LauncherCodePath, "project");
|
||
|
|
||
|
var buildDirectory = Path.Combine(projectPath, "Build");
|
||
|
|
||
|
CreateDirectory(buildDirectory);
|
||
|
|
||
|
var publishSettings = new DotNetCorePublishSettings
|
||
|
{
|
||
|
Configuration = "Release",
|
||
|
Runtime = "win10-x64",
|
||
|
NoRestore = true,
|
||
|
PublishSingleFile = true,
|
||
|
SelfContained = false,
|
||
|
OutputDirectory = buildDirectory
|
||
|
};
|
||
|
|
||
|
DotNetCorePublish(Path.Combine(projectPath, "Aki.Launcher", "Aki.Launcher.csproj"), publishSettings);
|
||
|
//DotNetCorePublish(Path.Combine(projectPath, "Aki.Launcher.CLI", "Aki.Launcher.CLI.csproj"), publishSettings);
|
||
|
|
||
|
CopyDirectory(Path.Combine(projectPath, "Aki.Launcher", "Aki_Data"), Path.Combine(buildDirectory, "Aki_Data"));
|
||
|
|
||
|
DeleteFiles(Path.Combine(buildDirectory, "*.pdb"));
|
||
|
|
||
|
//CopyFileToDirectory(Path.Combine(projectPath, "Aki.Launcher", "bin", "Release", "net5.0-windows", "win10-x64", "Launcher.exe"), );
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------------------
|
||
|
// Modules
|
||
|
// ------------------------------------------------------------------
|
||
|
|
||
|
Task("Clean:Modules")
|
||
|
.WithCriteria(!skipClean)
|
||
|
.Does(() =>
|
||
|
{
|
||
|
Information("Cleaning modules build folder");
|
||
|
CleanDirectory(Path.Combine(config.ModulesCodePath, "project", "Build"));
|
||
|
|
||
|
Information("Cleaning modules bin folders");
|
||
|
DotNetCoreClean(Path.Combine(config.ModulesCodePath, "project", "Modules.sln"), new DotNetCoreCleanSettings
|
||
|
{
|
||
|
Configuration = "Release",
|
||
|
DiagnosticOutput = false,
|
||
|
NoLogo = true,
|
||
|
Verbosity = DotNetCoreVerbosity.Minimal
|
||
|
});
|
||
|
});
|
||
|
|
||
|
Task("Restore:Modules")
|
||
|
.Does(() =>
|
||
|
{
|
||
|
// var buildSettings = new MSBuildSettings
|
||
|
// {
|
||
|
// Configuration = "Release",
|
||
|
// Restore = false
|
||
|
// };
|
||
|
|
||
|
// buildSettings.Targets.Add("build");
|
||
|
|
||
|
// MSBuild(Path.Combine(config.ModulesCodePath, "project", "Modules.sln"));
|
||
|
});
|
||
|
|
||
|
Task("Build:Modules")
|
||
|
.IsDependentOn("Clean:Modules")
|
||
|
.IsDependentOn("Restore:Modules")
|
||
|
.Does(() =>
|
||
|
{
|
||
|
Information("Building modules solution");
|
||
|
|
||
|
var projectPath = Path.Combine(config.ModulesCodePath, "project");
|
||
|
|
||
|
var buildDirectory = Path.Combine(projectPath, "Build");
|
||
|
|
||
|
CreateDirectory(buildDirectory);
|
||
|
|
||
|
var buildSettings = new MSBuildSettings
|
||
|
{
|
||
|
Configuration = "Release",
|
||
|
Restore = true,
|
||
|
ArgumentCustomization = builder => builder.Append("-m")
|
||
|
};
|
||
|
|
||
|
buildSettings.Targets.Add("build");
|
||
|
|
||
|
MSBuild(Path.Combine(projectPath, "Modules.sln"), buildSettings);
|
||
|
|
||
|
Information("Assembling output build directory");
|
||
|
|
||
|
var buildModulesDirectory = Path.Combine(buildDirectory, "Aki_Data", "Modules");
|
||
|
|
||
|
CreateDirectory(Path.Combine(buildModulesDirectory, "aki-core"));
|
||
|
CreateDirectory(Path.Combine(buildModulesDirectory, "aki-singleplayer"));
|
||
|
|
||
|
CopyFile(Path.Combine(projectPath, "Aki.Core", "bin", "Release", "aki-core.dll"),
|
||
|
Path.Combine(buildModulesDirectory, "aki-core", "module.dll"));
|
||
|
|
||
|
CopyFile(Path.Combine(projectPath, "Aki.SinglePlayer", "bin", "Release", "aki-singleplayer.dll"),
|
||
|
Path.Combine(buildModulesDirectory, "aki-singleplayer", "module.dll"));
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
var managedFolder = Path.Combine(buildDirectory, "EscapeFromTarkov_Data", "Managed");
|
||
|
CreateDirectory(managedFolder);
|
||
|
|
||
|
CopyFileToDirectory(Path.Combine(projectPath, "Aki.Core", "bin", "Release", "FilesChecker.dll"), managedFolder);
|
||
|
CopyFileToDirectory(Path.Combine(projectPath, "Aki.Common", "bin", "Release", "Aki.Common.dll"), managedFolder);
|
||
|
CopyFileToDirectory(Path.Combine(projectPath, "Aki.Reflection", "bin", "Release", "Aki.Reflection.dll"), managedFolder);
|
||
|
CopyFileToDirectory(Path.Combine(projectPath, "Aki.Loader", "bin", "Release", "NLog.Aki.Loader.dll"), managedFolder);
|
||
|
|
||
|
CopyFiles(Path.Combine(projectPath, "Aki.Reflection", "bin", "Release", "*.dll"), managedFolder);
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------------------
|
||
|
// Server
|
||
|
// ------------------------------------------------------------------
|
||
|
|
||
|
int RunNpm(string argument)
|
||
|
{
|
||
|
var projectDirectory = Path.Combine(config.ServerCodePath, "project");
|
||
|
|
||
|
var npm = IsRunningOnWindows() ? Context.Tools.Resolve("npm.cmd")
|
||
|
: Context.Tools.Resolve("npm");
|
||
|
|
||
|
Information(npm);
|
||
|
|
||
|
return StartProcess(npm, new ProcessSettings
|
||
|
{
|
||
|
Arguments = argument,
|
||
|
WorkingDirectory = projectDirectory
|
||
|
});
|
||
|
}
|
||
|
|
||
|
Task("Clean:Server")
|
||
|
.WithCriteria(!skipClean)
|
||
|
.Does(() =>
|
||
|
{
|
||
|
Information("Cleaning server build folder");
|
||
|
CleanDirectory(Path.Combine(config.ServerCodePath, "project", "build"));
|
||
|
});
|
||
|
|
||
|
Task("Restore:Server")
|
||
|
.Does(() =>
|
||
|
{
|
||
|
Information("Installing server NPM packages");
|
||
|
|
||
|
RunNpm("install");
|
||
|
});
|
||
|
|
||
|
Task("Build:Server")
|
||
|
.IsDependentOn("Clean:Server")
|
||
|
.IsDependentOn("Restore:Server")
|
||
|
.Does(() =>
|
||
|
{
|
||
|
Information("Building server");
|
||
|
|
||
|
RunNpm("run build:release");
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------------------
|
||
|
// Packaging
|
||
|
// ------------------------------------------------------------------
|
||
|
|
||
|
Task("Build")
|
||
|
//.WithCriteria(!skipBuild)
|
||
|
.Does(() =>
|
||
|
{
|
||
|
RunTarget("Build:Launcher");
|
||
|
RunTarget("Build:Modules");
|
||
|
RunTarget("Build:Server");
|
||
|
});
|
||
|
|
||
|
Task("Restore")
|
||
|
.IsDependentOn("Restore:Launcher")
|
||
|
.IsDependentOn("Restore:Modules")
|
||
|
.IsDependentOn("Restore:Server")
|
||
|
.Does(() =>
|
||
|
{
|
||
|
|
||
|
});
|
||
|
|
||
|
Task("Package")
|
||
|
.IsDependentOn("Build")
|
||
|
.Does(() =>
|
||
|
{
|
||
|
var tempBuildFolder = Path.GetFullPath(Path.Combine(".", "TempBuild"));
|
||
|
|
||
|
if (DirectoryExists(tempBuildFolder)) {
|
||
|
DeleteDirectory(tempBuildFolder, new DeleteDirectorySettings {
|
||
|
Recursive = true
|
||
|
});
|
||
|
}
|
||
|
|
||
|
CreateDirectory(tempBuildFolder);
|
||
|
|
||
|
|
||
|
CopyFiles(Path.Combine(config.LauncherCodePath, "project", "Build", "**/*"), tempBuildFolder, true);
|
||
|
CopyFiles(Path.Combine(config.ModulesCodePath, "project", "Build", "**/*"), tempBuildFolder, true);
|
||
|
CopyFiles(Path.Combine(config.ServerCodePath, "project", "build", "**/*"), tempBuildFolder, true);
|
||
|
|
||
|
DeleteFile(Path.Combine(tempBuildFolder, "LauncherCLI.exe"));
|
||
|
|
||
|
Zip(tempBuildFolder, "AkiRelease.zip");
|
||
|
|
||
|
DeleteDirectory(tempBuildFolder, new DeleteDirectorySettings {
|
||
|
Recursive = true
|
||
|
});
|
||
|
});
|
||
|
|
||
|
Task("CopyDev")
|
||
|
.IsDependentOn("Build")
|
||
|
.Does(() =>
|
||
|
{
|
||
|
// if (!preserveDevFolder && DirectoryExists(config.DevGameFolder)) {
|
||
|
// DeleteDirectory(config.DevGameFolder, new DeleteDirectorySettings {
|
||
|
// Recursive = true
|
||
|
// });
|
||
|
// }
|
||
|
|
||
|
CopyFiles(Path.Combine(config.LauncherCodePath, "project", "Build", "**/*"), config.DevGameFolder, true);
|
||
|
CopyFiles(Path.Combine(config.ModulesCodePath, "project", "Build", "**/*"), config.DevGameFolder, true);
|
||
|
CopyFiles(Path.Combine(config.ServerCodePath, "project", "build", "**/*"), config.DevGameFolder, true);
|
||
|
});
|
||
|
|
||
|
Information("skipbuild: " + skipBuild);
|
||
|
|
||
|
RunTarget(target);
|