Configuration argument for content packaging (#25569)

* Configuration argument for content packaging

Needed this for something so here we are. I think someone mentioned they wanted this? Welp its here now

* Add client, tiny fixes
This commit is contained in:
Vasilis
2024-03-24 03:20:34 +01:00
committed by GitHub
parent 4c840a7e6a
commit 9e7b196ffb
4 changed files with 34 additions and 15 deletions

View File

@@ -13,7 +13,7 @@ public static class ClientPackaging
/// <summary> /// <summary>
/// Be advised this can be called from server packaging during a HybridACZ build. /// Be advised this can be called from server packaging during a HybridACZ build.
/// </summary> /// </summary>
public static async Task PackageClient(bool skipBuild, IPackageLogger logger) public static async Task PackageClient(bool skipBuild, string configuration, IPackageLogger logger)
{ {
logger.Info("Building client..."); logger.Info("Building client...");
@@ -26,7 +26,7 @@ public static class ClientPackaging
{ {
"build", "build",
Path.Combine("Content.Client", "Content.Client.csproj"), Path.Combine("Content.Client", "Content.Client.csproj"),
"-c", "Release", "-c", configuration,
"--nologo", "--nologo",
"/v:m", "/v:m",
"/t:Rebuild", "/t:Rebuild",

View File

@@ -31,6 +31,11 @@ public sealed class CommandLineArgs
/// </summary> /// </summary>
public bool HybridAcz { get; set; } public bool HybridAcz { get; set; }
/// <summary>
/// Configuration used for when packaging the server. (Release, Debug, Tools)
/// </summary>
public string Configuration { get; set; }
// CommandLineArgs, 3rd of her name. // CommandLineArgs, 3rd of her name.
public static bool TryParse(IReadOnlyList<string> args, [NotNullWhen(true)] out CommandLineArgs? parsed) public static bool TryParse(IReadOnlyList<string> args, [NotNullWhen(true)] out CommandLineArgs? parsed)
{ {
@@ -39,6 +44,7 @@ public sealed class CommandLineArgs
var skipBuild = false; var skipBuild = false;
var wipeRelease = true; var wipeRelease = true;
var hybridAcz = false; var hybridAcz = false;
var configuration = "Release";
List<string>? platforms = null; List<string>? platforms = null;
using var enumerator = args.GetEnumerator(); using var enumerator = args.GetEnumerator();
@@ -89,6 +95,16 @@ public sealed class CommandLineArgs
platforms ??= new List<string>(); platforms ??= new List<string>();
platforms.Add(enumerator.Current); platforms.Add(enumerator.Current);
} }
else if (arg == "--configuration")
{
if (!enumerator.MoveNext())
{
Console.WriteLine("No configuration provided");
return false;
}
configuration = enumerator.Current;
}
else if (arg == "--help") else if (arg == "--help")
{ {
PrintHelp(); PrintHelp();
@@ -106,7 +122,7 @@ public sealed class CommandLineArgs
return false; return false;
} }
parsed = new CommandLineArgs(client.Value, skipBuild, wipeRelease, hybridAcz, platforms); parsed = new CommandLineArgs(client.Value, skipBuild, wipeRelease, hybridAcz, platforms, configuration);
return true; return true;
} }
@@ -120,6 +136,7 @@ Options:
--no-wipe-release Don't wipe the release folder before creating files. --no-wipe-release Don't wipe the release folder before creating files.
--hybrid-acz Use HybridACZ for server builds. --hybrid-acz Use HybridACZ for server builds.
--platform Platform for server builds. Default will output several x64 targets. --platform Platform for server builds. Default will output several x64 targets.
--configuration Configuration to use for building the server (Release, Debug, Tools). Default is Release.
"); ");
} }
@@ -128,12 +145,14 @@ Options:
bool skipBuild, bool skipBuild,
bool wipeRelease, bool wipeRelease,
bool hybridAcz, bool hybridAcz,
List<string>? platforms) List<string>? platforms,
string configuration)
{ {
Client = client; Client = client;
SkipBuild = skipBuild; SkipBuild = skipBuild;
WipeRelease = wipeRelease; WipeRelease = wipeRelease;
HybridAcz = hybridAcz; HybridAcz = hybridAcz;
Platforms = platforms; Platforms = platforms;
Configuration = configuration;
} }
} }

View File

@@ -17,11 +17,11 @@ if (!parsed.SkipBuild)
if (parsed.Client) if (parsed.Client)
{ {
await ClientPackaging.PackageClient(parsed.SkipBuild, logger); await ClientPackaging.PackageClient(parsed.SkipBuild, parsed.Configuration, logger);
} }
else else
{ {
await ServerPackaging.PackageServer(parsed.SkipBuild, parsed.HybridAcz, logger, parsed.Platforms); await ServerPackaging.PackageServer(parsed.SkipBuild, parsed.HybridAcz, logger, parsed.Configuration, parsed.Platforms);
} }
void WipeBin() void WipeBin()

View File

@@ -69,7 +69,7 @@ public static class ServerPackaging
"zh-Hant" "zh-Hant"
}; };
public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageLogger logger, List<string>? platforms = null) public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageLogger logger, string configuration, List<string>? platforms = null)
{ {
if (platforms == null) if (platforms == null)
{ {
@@ -82,7 +82,7 @@ public static class ServerPackaging
// Rather than hosting the client ZIP on the watchdog or on a separate server, // Rather than hosting the client ZIP on the watchdog or on a separate server,
// Hybrid ACZ uses the ACZ hosting functionality to host it as part of the status host, // Hybrid ACZ uses the ACZ hosting functionality to host it as part of the status host,
// which means that features such as automatic UPnP forwarding still work properly. // which means that features such as automatic UPnP forwarding still work properly.
await ClientPackaging.PackageClient(skipBuild, logger); await ClientPackaging.PackageClient(skipBuild, configuration, logger);
} }
// Good variable naming right here. // Good variable naming right here.
@@ -91,13 +91,13 @@ public static class ServerPackaging
if (!platforms.Contains(platform.Rid)) if (!platforms.Contains(platform.Rid))
continue; continue;
await BuildPlatform(platform, skipBuild, hybridAcz, logger); await BuildPlatform(platform, skipBuild, hybridAcz, configuration, logger);
} }
} }
private static async Task BuildPlatform(PlatformReg platform, bool skipBuild, bool hybridAcz, IPackageLogger logger) private static async Task BuildPlatform(PlatformReg platform, bool skipBuild, bool hybridAcz, string configuration, IPackageLogger logger)
{ {
logger.Info($"Building project for {platform}..."); logger.Info($"Building project for {platform.TargetOs}...");
if (!skipBuild) if (!skipBuild)
{ {
@@ -108,7 +108,7 @@ public static class ServerPackaging
{ {
"build", "build",
Path.Combine("Content.Server", "Content.Server.csproj"), Path.Combine("Content.Server", "Content.Server.csproj"),
"-c", "Release", "-c", configuration,
"--nologo", "--nologo",
"/v:m", "/v:m",
$"/p:TargetOs={platform.TargetOs}", $"/p:TargetOs={platform.TargetOs}",
@@ -118,7 +118,7 @@ public static class ServerPackaging
} }
}); });
await PublishClientServer(platform.Rid, platform.TargetOs); await PublishClientServer(platform.Rid, platform.TargetOs, configuration);
} }
logger.Info($"Packaging {platform.Rid} server..."); logger.Info($"Packaging {platform.Rid} server...");
@@ -137,7 +137,7 @@ public static class ServerPackaging
logger.Info($"Finished packaging server in {sw.Elapsed}"); logger.Info($"Finished packaging server in {sw.Elapsed}");
} }
private static async Task PublishClientServer(string runtime, string targetOs) private static async Task PublishClientServer(string runtime, string targetOs, string configuration)
{ {
await ProcessHelpers.RunCheck(new ProcessStartInfo await ProcessHelpers.RunCheck(new ProcessStartInfo
{ {
@@ -147,7 +147,7 @@ public static class ServerPackaging
"publish", "publish",
"--runtime", runtime, "--runtime", runtime,
"--no-self-contained", "--no-self-contained",
"-c", "Release", "-c", configuration,
$"/p:TargetOs={targetOs}", $"/p:TargetOs={targetOs}",
"/p:FullRelease=True", "/p:FullRelease=True",
"/m", "/m",