diff --git a/Editor/Logging/AbstractCILogger.cs b/Editor/Logging/AbstractCILogger.cs
index 61ccde8..d1ffe67 100644
--- a/Editor/Logging/AbstractCILogger.cs
+++ b/Editor/Logging/AbstractCILogger.cs
@@ -2,6 +2,7 @@
using System;
using System.Linq;
+using UnityEditor.Build.Reporting;
using UnityEngine;
using Object = UnityEngine.Object;
@@ -88,5 +89,8 @@ public void LogException(Exception exception, Object context)
///
public virtual string ResetColor => "\u001b[0m";
+
+ ///
+ public virtual void GenerateBuildSummary(BuildReport buildReport) { }
}
}
diff --git a/Editor/Logging/CILoggingUtility.cs b/Editor/Logging/CILoggingUtility.cs
index d84e195..ea347e5 100644
--- a/Editor/Logging/CILoggingUtility.cs
+++ b/Editor/Logging/CILoggingUtility.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using UnityEditor;
+using UnityEditor.Build.Reporting;
using UnityEngine;
namespace Utilities.Editor.BuildPipeline.Logging
@@ -62,5 +63,7 @@ static CILoggingUtility()
Logger = new GitHubActionsLogger();
}
}
+
+ public static void GenerateBuildReport(BuildReport buildReport) => Logger?.GenerateBuildSummary(buildReport);
}
}
diff --git a/Editor/Logging/GitHubActionsLogger.cs b/Editor/Logging/GitHubActionsLogger.cs
index 521938b..cc6a8fd 100644
--- a/Editor/Logging/GitHubActionsLogger.cs
+++ b/Editor/Logging/GitHubActionsLogger.cs
@@ -1,5 +1,9 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.
+using System;
+using UnityEditor.Build.Reporting;
+using UnityEngine;
+
namespace Utilities.Editor.BuildPipeline.Logging
{
///
@@ -13,5 +17,52 @@ public class GitHubActionsLogger : AbstractCILogger
///
public override string Error => "::error::";
+
+ ///
+ public override void GenerateBuildSummary(BuildReport buildReport)
+ {
+ var buildResultMessage = $"Build success? {buildReport.summary.result}\nBuild time: {buildReport.summary.totalTime:g}";
+
+ switch (buildReport.summary.result)
+ {
+ case BuildResult.Succeeded:
+ Debug.Log($"::notice::{buildResultMessage}");
+ break;
+ case BuildResult.Unknown:
+ case BuildResult.Cancelled:
+ Debug.Log($"{Warning}{buildResultMessage}");
+ break;
+ case BuildResult.Failed:
+ Debug.Log($"{Error}{buildResultMessage}");
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ foreach (var step in buildReport.steps)
+ {
+ Debug.Log($"::notice::Build Step: {step.name} | Duration: {step.duration:g}");
+
+ foreach (var message in step.messages)
+ {
+ switch (message.type)
+ {
+ case LogType.Error:
+ case LogType.Assert:
+ case LogType.Exception:
+ Debug.Log($"{Error} {message.content}");
+ break;
+ case LogType.Warning:
+ Debug.Log($"{Warning} {message.content}");
+ break;
+ case LogType.Log:
+ Debug.Log($"{message.content}");
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+ }
+ }
}
}
diff --git a/Editor/Logging/ICILogger.cs b/Editor/Logging/ICILogger.cs
index 149581b..3b38d85 100644
--- a/Editor/Logging/ICILogger.cs
+++ b/Editor/Logging/ICILogger.cs
@@ -1,5 +1,6 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.
+using UnityEditor.Build.Reporting;
using UnityEngine;
namespace Utilities.Editor.BuildPipeline.Logging
@@ -43,5 +44,11 @@ public interface ICILogger : ILogHandler
/// ANSI Reset color code.
///
string ResetColor { get; }
+
+ ///
+ /// Generate a nicely formatted build summary for the CI Logger.
+ ///
+ /// .
+ void GenerateBuildSummary(BuildReport buildReport);
}
}
diff --git a/Editor/UnityPlayerBuildTools.cs b/Editor/UnityPlayerBuildTools.cs
index 5a4b00d..5057cb6 100644
--- a/Editor/UnityPlayerBuildTools.cs
+++ b/Editor/UnityPlayerBuildTools.cs
@@ -352,26 +352,8 @@ public static void StartCommandLineBuild()
return;
}
- var buildResultMessage = $"Exiting command line build...\nBuild success? {buildReport.summary.result}\nBuild time: {buildReport.summary.totalTime:g}";
- var buildEventLogs = string.Join("\n", buildReport.steps.SelectMany(step => step.messages.Select(message => $"[{message.type}] {message.content}")));
-
- switch (buildReport.summary.result)
- {
- case BuildResult.Succeeded:
- Debug.Log(buildResultMessage);
- break;
- case BuildResult.Unknown:
- case BuildResult.Cancelled:
- Debug.LogWarning($"{buildResultMessage}\nBuild Event Logs:\n{buildEventLogs}");
- break;
- case BuildResult.Failed:
- Debug.LogWarning($"{buildResultMessage}\nBuild Event Logs:\n{buildEventLogs}");
- break;
-
- default:
- throw new ArgumentOutOfRangeException();
- }
-
+ CILoggingUtility.GenerateBuildReport(buildReport);
+ Debug.Log("Exiting command line build...");
EditorApplication.Exit(buildReport.summary.result == BuildResult.Succeeded ? 0 : 1);
}
diff --git a/package.json b/package.json
index 56f71c3..2bf7160 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"displayName": "Build Pipeline Utilities",
"description": "The Build Pipeline Utilities aims to give developers more tools and options when making builds with the command line or with continuous integration.",
"keywords": [],
- "version": "1.0.9",
+ "version": "1.1.0",
"unity": "2019.4",
"license": "MIT",
"repository": {