Skip to content

Commit 2b1dd2c

Browse files
committed
Print all lines, not just error lines, when a tool hits an error
1 parent 3e7f9e8 commit 2b1dd2c

File tree

1 file changed

+5
-46
lines changed

1 file changed

+5
-46
lines changed

src/winapp-CLI/WinApp.Cli/Services/BuildToolsService.cs

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -282,27 +282,6 @@ public async Task<FileInfo> EnsureBuildToolAvailableAsync(string toolName, Cance
282282
return binPath;
283283
}
284284

285-
/// <summary>
286-
/// Determines if a line from build tool output contains an error message
287-
/// </summary>
288-
/// <param name="line">The line to check</param>
289-
/// <returns>True if the line contains an error message, false otherwise</returns>
290-
private static bool IsErrorLine(string line)
291-
{
292-
// Here's some example error strings from the tools we call:
293-
// mt.exe:
294-
// \\?\D:\temp\asdf.manife : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
295-
// signtool.exe:
296-
// SignTool Error: No file digest algorithm specified. Please specify the digest algorithm with the /fd flag. Using ...
297-
// makepri.exe:
298-
// ERROR: PRI180: 0x80070057 - Target noexist.dmp does not exist
299-
// makeappx.exe:
300-
// MakeAppx : error: Package creation failed.
301-
// MakeAppx : error: 0x80080204 - The specified package format is not valid: The package manifest is not valid.
302-
303-
return ErrorLineRegex().IsMatch(line);
304-
}
305-
306285
/// <summary>
307286
/// Execute a build tool with the specified arguments
308287
/// </summary>
@@ -346,32 +325,19 @@ private static bool IsErrorLine(string line)
346325

347326
if (p.ExitCode != 0)
348327
{
349-
// Print lines containing errors from both stdout and stderr when not in verbose mode.
328+
// Print lines from both stdout and stderr when not in verbose mode so the user can determine
329+
// what went wrong.
350330
// In verbose mode, all output is already visible via LogDebug above.
351331
if (!logger.IsEnabled(LogLevel.Debug))
352332
{
353333
if (!string.IsNullOrWhiteSpace(stdout))
354334
{
355-
var stdoutLines = stdout.Split('\n', StringSplitOptions.RemoveEmptyEntries);
356-
foreach (var line in stdoutLines)
357-
{
358-
if (IsErrorLine(line))
359-
{
360-
logger.LogError("{ErrorLine}", line);
361-
}
362-
}
335+
logger.LogError("{Stdout}", stdout);
363336
}
364-
337+
365338
if (!string.IsNullOrWhiteSpace(stderr))
366339
{
367-
var stderrLines = stderr.Split('\n', StringSplitOptions.RemoveEmptyEntries);
368-
foreach (var line in stderrLines)
369-
{
370-
if (IsErrorLine(line))
371-
{
372-
logger.LogError("{ErrorLine}", line);
373-
}
374-
}
340+
logger.LogError("{StdErr}", stderr);
375341
}
376342
}
377343

@@ -397,11 +363,4 @@ public InvalidBuildToolException(int processId, string stdout, string stderr, st
397363

398364
[GeneratedRegex(@"^\d+\.\d+\.\d+\.\d+$")]
399365
private static partial Regex VersionFolderRegex();
400-
401-
// Recognize lines that look like error information.
402-
// Example strings we want to match:
403-
// error:
404-
// general error c1010070:
405-
[GeneratedRegex(@"error\s+[a-z]?\d+:|error:", RegexOptions.IgnoreCase)]
406-
private static partial Regex ErrorLineRegex();
407366
}

0 commit comments

Comments
 (0)