MahApps/MahApps.Metro · error · Exception
Errors occurred:{Environment.NewLine} {string.Join(Environme
Error message
Errors occurred:{Environment.NewLine} {string.Join(Environment.NewLine, process.GetStandardError())} What it means
Inside ExecuteProcess (build.cake:429-433), after the external process exits the build checks whether anything was written to standard error. If process.GetStandardError() contains any line, it throws an Exception joining all stderr lines, regardless of the exit code. This is stricter than exit-code checking: even a tool that returns 0 will fail the build if it prints to stderr.
Source
Thrown at build.cake:432
{
processSettings.WorkingDirectory = workingDirectory;
}
Information($"Arguments: {arguments.RenderSafe()}");
using(var process = StartAndReturnProcess(fileName, processSettings))
{
process.WaitForExit();
if (process.GetStandardOutput().Any())
{
Information($"Output:{Environment.NewLine} {string.Join(Environment.NewLine, process.GetStandardOutput())}");
}
if (process.GetStandardError().Any())
{
// Information($"Errors occurred:{Environment.NewLine} {string.Join(Environment.NewLine, process.GetStandardError())}");
throw new Exception($"Errors occurred:{Environment.NewLine} {string.Join(Environment.NewLine, process.GetStandardError())}");
}
// This should output 0 as valid arguments supplied
var exitCode = process.GetExitCode();
Information($"Exit code: {exitCode}");
if (exitCode > 0)
{
throw new Exception($"Exit code: {exitCode}");
}
}
}
///////////////////////////////////////////////////////////////////////////////
// TASK TARGETS
///////////////////////////////////////////////////////////////////////////////
Task("Default")View on GitHub (pinned to 72099e310b)
Solutions
- Inspect the captured stderr in the exception message to see exactly what the tool reported; address the root cause the tool is complaining about.
- If the stderr is benign (warnings/notices), downgrade the tool to a version that does not write to stderr on success, or pass a flag that silences verbose/diagnostic output.
- Reconfigure the tool to write diagnostics to stdout or a log file instead of stderr.
- If you control build.cake, consider distinguishing fatal errors from warnings rather than treating all stderr as failure.
Example fix
// before: any stderr line fails the build
if (process.GetStandardError().Any())
{
throw new Exception($"Errors occurred:{Environment.NewLine} {string.Join(Environment.NewLine, process.GetStandardError())}");
}
// after: only fail on non-zero exit code, log stderr as warning
var stderr = process.GetStandardError();
if (stderr.Any())
{
Warning($"Stderr from {fileName}:{Environment.NewLine}{string.Join(Environment.NewLine, stderr)}");
} Defensive patterns
Strategy: try-catch
Try / catch
// When wrapping ExecuteProcess, capture the stderr text and decide whether it is fatal
try {
ExecuteProcess(styler, args);
} catch (Exception ex) when (ex.Message.StartsWith("Errors occurred")) {
if (IsBenignStderr(ex.Message)) { Warning($"Tool emitted stderr: {ex.Message}"); }
else throw;
} Prevention
- When you control the tool, configure it to write only errors (not warnings/notices) to stderr.
- Pin tool versions known to not write diagnostics to stderr on success.
- Prefer treating exit code as the source of truth; route stderr to the log and only fail on non-zero codes.
- When authoring a build helper, separate fatal stderr from informational stderr.
When it happens
Trigger: Any tool invoked via ExecuteProcess writes one or more lines to stderr — a warning, a deprecation notice, or a genuine error. The check fires before the exit code is examined, so even successful runs that emit stderr are treated as failures.
Common situations: XAML Styler or another tool emits a warning/notice to stderr on success. A newer version of a tool started writing verbose diagnostics to stderr. Code-signing tool emits status text to stderr. Cross-platform tooling differences where Windows writes to stdout but the same tool writes to stderr elsewhere.
Related errors
- File not found: {fileName}
- Exit code: {exitCode}
- {repoName} will only build on Windows because it's not possi
- The GITHUB_TOKEN environment variable is not defined.
AI-assisted analysis of MahApps/MahApps.Metro@72099e310b (2026-08-13).
Data as JSON: /api/errors/e31b9ba9256396b0.
Report an issue: GitHub.