Content.Packaging can now emit binlogs for the build (#42659)

* Content.Packaging can now emit binlogs for the build

I was checking why packaging is so much slower and it *seems* to be entirely the actual build being twice as slow as before .NET 10. Strange.

Content.Packaging can now emit MSBuild binlogs that we can analyze to see why that's the case.

* Enable --log-build on Test Packaging workflow, produce artifact with binlogs

* Disable setup-dotnet in packaging workflow

I have a suspicion...
This commit is contained in:
Pieter-Jan Briers
2026-01-27 01:39:00 +01:00
committed by GitHub
parent b625152511
commit d11f3fb3c1
5 changed files with 59 additions and 18 deletions

View File

@@ -48,10 +48,11 @@ jobs:
cd RobustToolbox/ cd RobustToolbox/
git submodule update --init --recursive git submodule update --init --recursive
- name: Setup .NET Core # ubuntu-latest has .NET 10
uses: actions/setup-dotnet@v4.1.0 # - name: Setup .NET Core
with: # uses: actions/setup-dotnet@v4.1.0
dotnet-version: 10.0.x # with:
# dotnet-version: 10.0.x
- name: Install dependencies - name: Install dependencies
run: dotnet restore run: dotnet restore
@@ -60,7 +61,13 @@ jobs:
run: dotnet build Content.Packaging --configuration Release --no-restore /m run: dotnet build Content.Packaging --configuration Release --no-restore /m
- name: Package server - name: Package server
run: dotnet run --project Content.Packaging server --platform win-x64 --platform win-arm64 --platform linux-x64 --platform linux-arm64 --platform osx-x64 --platform osx-arm64 run: dotnet run --project Content.Packaging server --log-build --platform win-x64 --platform win-arm64 --platform linux-x64 --platform linux-arm64 --platform osx-x64 --platform osx-arm64
- name: Package client - name: Package client
run: dotnet run --project Content.Packaging client --no-wipe-release run: dotnet run --project Content.Packaging client --log-build --no-wipe-release
- uses: actions/upload-artifact@v4
with:
name: binlogs
path: release/*.binlog
retention-days: 7

View File

@@ -13,13 +13,13 @@ 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, string configuration, IPackageLogger logger) public static async Task PackageClient(bool skipBuild, bool logBuild, string configuration, IPackageLogger logger)
{ {
logger.Info("Building client..."); logger.Info("Building client...");
if (!skipBuild) if (!skipBuild)
{ {
await ProcessHelpers.RunCheck(new ProcessStartInfo var startInfo = new ProcessStartInfo
{ {
FileName = "dotnet", FileName = "dotnet",
ArgumentList = ArgumentList =
@@ -33,7 +33,15 @@ public static class ClientPackaging
"/p:FullRelease=true", "/p:FullRelease=true",
"/m" "/m"
} }
}); };
if (logBuild)
{
startInfo.ArgumentList.Add($"/bl:{Path.Combine("release", "client.binlog")}");
startInfo.ArgumentList.Add("/p:ReportAnalyzer=true");
}
await ProcessHelpers.RunCheck(startInfo);
} }
logger.Info("Packaging client..."); logger.Info("Packaging client...");

View File

@@ -36,6 +36,11 @@ public sealed class CommandLineArgs
/// </summary> /// </summary>
public string Configuration { get; set; } public string Configuration { get; set; }
/// <summary>
/// Log builds with MSBuild binlog. Logs get saved to release/
/// </summary>
public bool LogBuild { 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)
{ {
@@ -44,6 +49,7 @@ public sealed class CommandLineArgs
var skipBuild = false; var skipBuild = false;
var wipeRelease = true; var wipeRelease = true;
var hybridAcz = false; var hybridAcz = false;
var logBuild = false;
var configuration = "Release"; var configuration = "Release";
List<string>? platforms = null; List<string>? platforms = null;
@@ -84,6 +90,10 @@ public sealed class CommandLineArgs
{ {
hybridAcz = true; hybridAcz = true;
} }
else if (arg == "--log-build")
{
logBuild = true;
}
else if (arg == "--platform") else if (arg == "--platform")
{ {
if (!enumerator.MoveNext()) if (!enumerator.MoveNext())
@@ -122,7 +132,7 @@ public sealed class CommandLineArgs
return false; return false;
} }
parsed = new CommandLineArgs(client.Value, skipBuild, wipeRelease, hybridAcz, platforms, configuration); parsed = new CommandLineArgs(client.Value, skipBuild, wipeRelease, hybridAcz, logBuild, platforms, configuration);
return true; return true;
} }
@@ -137,6 +147,7 @@ Options:
--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. --configuration Configuration to use for building the server (Release, Debug, Tools). Default is Release.
--log-build Log builds with MSBuild binlog. Logs get saved to release/
"); ");
} }
@@ -145,6 +156,7 @@ Options:
bool skipBuild, bool skipBuild,
bool wipeRelease, bool wipeRelease,
bool hybridAcz, bool hybridAcz,
bool logBuild,
List<string>? platforms, List<string>? platforms,
string configuration) string configuration)
{ {
@@ -154,5 +166,6 @@ Options:
HybridAcz = hybridAcz; HybridAcz = hybridAcz;
Platforms = platforms; Platforms = platforms;
Configuration = configuration; Configuration = configuration;
LogBuild = logBuild;
} }
} }

View File

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

View File

@@ -60,7 +60,7 @@ public static class ServerPackaging
"zh-Hant" "zh-Hant"
}; };
public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageLogger logger, string configuration, List<string>? platforms = null) public static async Task PackageServer(bool skipBuild, bool hybridAcz, bool logBuild, IPackageLogger logger, string configuration, List<string>? platforms = null)
{ {
if (platforms == null) if (platforms == null)
{ {
@@ -73,7 +73,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, configuration, logger); await ClientPackaging.PackageClient(skipBuild, logBuild, configuration, logger);
} }
// Good variable naming right here. // Good variable naming right here.
@@ -82,17 +82,22 @@ public static class ServerPackaging
if (!platforms.Contains(platform.Rid)) if (!platforms.Contains(platform.Rid))
continue; continue;
await BuildPlatform(platform, skipBuild, hybridAcz, configuration, logger); await BuildPlatform(platform, skipBuild, hybridAcz, logBuild, configuration, logger);
} }
} }
private static async Task BuildPlatform(PlatformReg platform, bool skipBuild, bool hybridAcz, string configuration, IPackageLogger logger) private static async Task BuildPlatform(PlatformReg platform,
bool skipBuild,
bool hybridAcz,
bool logBuild,
string configuration,
IPackageLogger logger)
{ {
logger.Info($"Building project for {platform.TargetOs}..."); logger.Info($"Building project for {platform.TargetOs}...");
if (!skipBuild) if (!skipBuild)
{ {
await ProcessHelpers.RunCheck(new ProcessStartInfo var startInfo = new ProcessStartInfo
{ {
FileName = "dotnet", FileName = "dotnet",
ArgumentList = ArgumentList =
@@ -107,7 +112,15 @@ public static class ServerPackaging
"/p:FullRelease=true", "/p:FullRelease=true",
"/m" "/m"
} }
}); };
if (logBuild)
{
startInfo.ArgumentList.Add($"/bl:{Path.Combine("release", $"server-{platform.Rid}.binlog")}");
startInfo.ArgumentList.Add("/p:ReportAnalyzer=true");
}
await ProcessHelpers.RunCheck(startInfo);
await PublishClientServer(platform.Rid, platform.TargetOs, configuration); await PublishClientServer(platform.Rid, platform.TargetOs, configuration);
} }