From 1f099727baff367a7568e0cd486f2a2609f1037a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 15 Apr 2025 10:04:28 +0200 Subject: [PATCH 1/2] Manual backport of reading binlog --- .../wasm/Wasm.Build.Tests/BuildTestBase.cs | 40 +++++++++++++++++++ .../Wasm.Build.Tests/Wasm.Build.Tests.csproj | 1 + 2 files changed, 41 insertions(+) diff --git a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs index cccc44efb621ee..4ac3be17fb615e 100644 --- a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs @@ -16,6 +16,7 @@ using Xunit; using Xunit.Abstractions; using Xunit.Sdk; +using Microsoft.Build.Logging.StructuredLogger; #nullable enable @@ -176,9 +177,48 @@ public BuildTestBase(ProjectProviderBase providerBase, ITestOutputHelper output, else if (res.ExitCode == 0) throw new XunitException($"Build should have failed, but it didn't. Process exited with exitCode : {res.ExitCode}"); + // Ensure we got all output. + string[] successMessages = ["Build succeeded"]; + string[] errorMessages = ["Build failed", "Build FAILED", "Restore failed", "Stopping the build"]; + if ((res.ExitCode == 0 && successMessages.All(m => !res.Output.Contains(m))) || (res.ExitCode != 0 && errorMessages.All(m => !res.Output.Contains(m)))) + { + _testOutput.WriteLine("Replacing dotnet process output with messages from binlog"); + + var outputBuilder = new StringBuilder(); + var buildRoot = BinaryLog.ReadBuild(logFilePath); + buildRoot.VisitAllChildren(m => + { + if (m is Message || m is Error || m is Warning) + { + var context = GetBinlogMessageContext(m); + outputBuilder.AppendLine($"{context}{m.Title}"); + } + }); + + res = new CommandResult(res.StartInfo, res.ExitCode, outputBuilder.ToString()); + } + return (res, logFilePath); } + private string GetBinlogMessageContext(TextNode node) + { + var currentNode = node; + while (currentNode != null) + { + if (currentNode is Error error) + { + return $"{error.File}({error.LineNumber},{error.ColumnNumber}): error {error.Code}: "; + } + else if (currentNode is Warning warning) + { + return $"{warning.File}({warning.LineNumber},{warning.ColumnNumber}): warning {warning.Code}: "; + } + currentNode = currentNode.Parent as TextNode; + } + return string.Empty; + } + protected string RunAndTestWasmApp(BuildArgs buildArgs, RunHost host, string id, diff --git a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj index 1c5ff4506db0ee..0b796d87bc0471 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj +++ b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj @@ -47,6 +47,7 @@ + From fee9b662224c57a89974dacfb5cdef3e301ee207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 15 Apr 2025 13:12:39 +0200 Subject: [PATCH 2/2] [torevert] Pin SDK in WBT --- eng/Versions.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index acdf4e0441a804..bdf3185ba53b12 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -262,8 +262,8 @@ 3.1.7 1.0.406601 - $(MicrosoftDotNetApiCompatTaskVersion) - + + 9.0.105 9.0.0-alpha.1.24175.1 $(MicrosoftNETRuntimeEmscriptenVersion) $(runtimewinx64MicrosoftNETCoreRuntimeWasmNodeTransportPackageVersion)