Preserve LogLevel when capturing output of a CommandLine in a C# Runner


In our current Unreal Engine project, we use C# script runners to run BuildGraph steps to automate our build process. We switched to C# runners from PowerShell because we want to be able to capture the output and also pipe it out to for the build logs. The captured output is parsed to schedule retries and clean retries automatically. Unfortunately, at least through the method we're using, Errors, Warnings, and other output which would normally be colored and marked according to their log level does not show up at all on TeamCity build logs. Essentially, all we do is run the required CommandLine, and store every line in a List of strings:

var buildLog = new List<string>();
    exitCode = cmd.Run(output =>


Can I change this code to preserve the LogLevel that you usually get from the log output of a build? I tried testing if output.IsError is true and using Error instead of WriteLine if it's true, but it never seems to be set to true. I've also played around with CMD line arguments sent to the Unreal Automation Tool, and none of them seem to help.



Please sign in to leave a comment.