Skip to content

Commit 9e7b196

Browse files
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
1 parent 4c840a7 commit 9e7b196

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

Content.Packaging/ClientPackaging.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static class ClientPackaging
1313
/// <summary>
1414
/// Be advised this can be called from server packaging during a HybridACZ build.
1515
/// </summary>
16-
public static async Task PackageClient(bool skipBuild, IPackageLogger logger)
16+
public static async Task PackageClient(bool skipBuild, string configuration, IPackageLogger logger)
1717
{
1818
logger.Info("Building client...");
1919

@@ -26,7 +26,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
2626
{
2727
"build",
2828
Path.Combine("Content.Client", "Content.Client.csproj"),
29-
"-c", "Release",
29+
"-c", configuration,
3030
"--nologo",
3131
"/v:m",
3232
"/t:Rebuild",

Content.Packaging/CommandLineArgs.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public sealed class CommandLineArgs
3131
/// </summary>
3232
public bool HybridAcz { get; set; }
3333

34+
/// <summary>
35+
/// Configuration used for when packaging the server. (Release, Debug, Tools)
36+
/// </summary>
37+
public string Configuration { get; set; }
38+
3439
// CommandLineArgs, 3rd of her name.
3540
public static bool TryParse(IReadOnlyList<string> args, [NotNullWhen(true)] out CommandLineArgs? parsed)
3641
{
@@ -39,6 +44,7 @@ public static bool TryParse(IReadOnlyList<string> args, [NotNullWhen(true)] out
3944
var skipBuild = false;
4045
var wipeRelease = true;
4146
var hybridAcz = false;
47+
var configuration = "Release";
4248
List<string>? platforms = null;
4349

4450
using var enumerator = args.GetEnumerator();
@@ -89,6 +95,16 @@ public static bool TryParse(IReadOnlyList<string> args, [NotNullWhen(true)] out
8995
platforms ??= new List<string>();
9096
platforms.Add(enumerator.Current);
9197
}
98+
else if (arg == "--configuration")
99+
{
100+
if (!enumerator.MoveNext())
101+
{
102+
Console.WriteLine("No configuration provided");
103+
return false;
104+
}
105+
106+
configuration = enumerator.Current;
107+
}
92108
else if (arg == "--help")
93109
{
94110
PrintHelp();
@@ -106,7 +122,7 @@ public static bool TryParse(IReadOnlyList<string> args, [NotNullWhen(true)] out
106122
return false;
107123
}
108124

109-
parsed = new CommandLineArgs(client.Value, skipBuild, wipeRelease, hybridAcz, platforms);
125+
parsed = new CommandLineArgs(client.Value, skipBuild, wipeRelease, hybridAcz, platforms, configuration);
110126
return true;
111127
}
112128

@@ -120,6 +136,7 @@ private static void PrintHelp()
120136
--no-wipe-release Don't wipe the release folder before creating files.
121137
--hybrid-acz Use HybridACZ for server builds.
122138
--platform Platform for server builds. Default will output several x64 targets.
139+
--configuration Configuration to use for building the server (Release, Debug, Tools). Default is Release.
123140
");
124141
}
125142

@@ -128,12 +145,14 @@ private CommandLineArgs(
128145
bool skipBuild,
129146
bool wipeRelease,
130147
bool hybridAcz,
131-
List<string>? platforms)
148+
List<string>? platforms,
149+
string configuration)
132150
{
133151
Client = client;
134152
SkipBuild = skipBuild;
135153
WipeRelease = wipeRelease;
136154
HybridAcz = hybridAcz;
137155
Platforms = platforms;
156+
Configuration = configuration;
138157
}
139158
}

Content.Packaging/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
if (parsed.Client)
1919
{
20-
await ClientPackaging.PackageClient(parsed.SkipBuild, logger);
20+
await ClientPackaging.PackageClient(parsed.SkipBuild, parsed.Configuration, logger);
2121
}
2222
else
2323
{
24-
await ServerPackaging.PackageServer(parsed.SkipBuild, parsed.HybridAcz, logger, parsed.Platforms);
24+
await ServerPackaging.PackageServer(parsed.SkipBuild, parsed.HybridAcz, logger, parsed.Configuration, parsed.Platforms);
2525
}
2626

2727
void WipeBin()

Content.Packaging/ServerPackaging.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static class ServerPackaging
6969
"zh-Hant"
7070
};
7171

72-
public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageLogger logger, List<string>? platforms = null)
72+
public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageLogger logger, string configuration, List<string>? platforms = null)
7373
{
7474
if (platforms == null)
7575
{
@@ -82,7 +82,7 @@ public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageL
8282
// Rather than hosting the client ZIP on the watchdog or on a separate server,
8383
// Hybrid ACZ uses the ACZ hosting functionality to host it as part of the status host,
8484
// which means that features such as automatic UPnP forwarding still work properly.
85-
await ClientPackaging.PackageClient(skipBuild, logger);
85+
await ClientPackaging.PackageClient(skipBuild, configuration, logger);
8686
}
8787

8888
// Good variable naming right here.
@@ -91,13 +91,13 @@ public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageL
9191
if (!platforms.Contains(platform.Rid))
9292
continue;
9393

94-
await BuildPlatform(platform, skipBuild, hybridAcz, logger);
94+
await BuildPlatform(platform, skipBuild, hybridAcz, configuration, logger);
9595
}
9696
}
9797

98-
private static async Task BuildPlatform(PlatformReg platform, bool skipBuild, bool hybridAcz, IPackageLogger logger)
98+
private static async Task BuildPlatform(PlatformReg platform, bool skipBuild, bool hybridAcz, string configuration, IPackageLogger logger)
9999
{
100-
logger.Info($"Building project for {platform}...");
100+
logger.Info($"Building project for {platform.TargetOs}...");
101101

102102
if (!skipBuild)
103103
{
@@ -108,7 +108,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
108108
{
109109
"build",
110110
Path.Combine("Content.Server", "Content.Server.csproj"),
111-
"-c", "Release",
111+
"-c", configuration,
112112
"--nologo",
113113
"/v:m",
114114
$"/p:TargetOs={platform.TargetOs}",
@@ -118,7 +118,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
118118
}
119119
});
120120

121-
await PublishClientServer(platform.Rid, platform.TargetOs);
121+
await PublishClientServer(platform.Rid, platform.TargetOs, configuration);
122122
}
123123

124124
logger.Info($"Packaging {platform.Rid} server...");
@@ -137,7 +137,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
137137
logger.Info($"Finished packaging server in {sw.Elapsed}");
138138
}
139139

140-
private static async Task PublishClientServer(string runtime, string targetOs)
140+
private static async Task PublishClientServer(string runtime, string targetOs, string configuration)
141141
{
142142
await ProcessHelpers.RunCheck(new ProcessStartInfo
143143
{
@@ -147,7 +147,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
147147
"publish",
148148
"--runtime", runtime,
149149
"--no-self-contained",
150-
"-c", "Release",
150+
"-c", configuration,
151151
$"/p:TargetOs={targetOs}",
152152
"/p:FullRelease=True",
153153
"/m",

0 commit comments

Comments
 (0)