Open MaceWindu opened 4 weeks ago
Hmm, looks like we can use dotnet msbuild
as workaround for now
Can you also try using dotnet build with the '--tl:off' flag? That'll disable the MSBuild Terminal Logger, which is the default starting in .Net 9. 'dotnet msbuild' doesn't use it as the default, so that could be one reason why using it works.
Nope, tried it already. Only tl:on works, but produce unreadable output due to control sequences
~Actually looks like -consoleloggerparameters:Summary
, which is used by dotnet build
also breaks dotnet msbuild
~
not working https://github.com/dotnet/msbuild/issues/10530#issuecomment-2293581921
~Checked other values for consoleloggerparameters
. Following also lead to hang:~
PerformanceSummary
~ShowCommandLine
~~Looks live it is not a blocker for us anymore with dotnet msbuild
~
not working https://github.com/dotnet/msbuild/issues/10530#issuecomment-2293581921
Thanks for the great research! That helps a lot.
Speaking personally I'd encourage folks to use dotnet build wherever possible instead of dotnet msbuild because build is a 'semantic' action that we can improve over time, whereas MSBuild is the generic, open-ended toolbox/escape hatch. Of course that doesn't work right now for you, but once this gets fixed I'd hope there wouldn't be other blockers to switching back for you.
~Also as dotnet build
pass parameters to msbuid, it is also possible to use -consoleloggerparameters:WarningsOnly;ErrorsOnly
with it to make it work as another workaround.~
actually no, as Summary also respected, it still hangs. Just not in my test-case
Tried to implement workaround in our code just to find out that it doesn't work. Issue reproduced with dotnet msbuild
too with provided repro code - just need to copy-paste properties in test.cs
to increase amount of errors. It looks like it depends on size of outputed logs somehow.
Maybe same as #6753 ? (env vars workaround doesn't work for me)
Out of ideas for workaround. Looks like I will need to use system-specific script to wrap dotnet
call with redirect to file and then read file 🥲
Looks like this works:
was:
await process.WaitForExitAsync(cancellationToken);
workaround:
var errors = new List<string>();
while (true)
{
var line = await process.StandardOutput.ReadLineAsync(cancellationToken);
if (line == null)
{
break;
}
errors.Add(line);
}
Updated issue report with proper analysis details
Also could confirm that same issue applicable to Linux (used mcr.microsoft.com/dotnet/sdk:8.0
docker image). Only difference is that after existing loop below
while (true)
{
var line = await process.StandardOutput.ReadLineAsync(cancellationToken);
if (line == null)
{
break;
}
errors.Add(line);
}
process.HasExisted
is false, so I need to use WaitForExitAsync
to ensure process terminated. So final working code is:
var logs = new List<string>();
while (true)
{
var line = await process.StandardOutput.ReadLineAsync(cancellationToken);
if (line == null)
{
break;
}
logs.Add(line);
}
await process.WaitForExitAsync(cancellationToken);
Updated 17/08/24 with more details
Issue Description
We are trying to build some code by calling
dotnet build
from our software and faced with dotnet process hangs under some conditions.Steps to Reproduce
Caller code
test project: 1111111111111111111111111111111111111111111111111111111111111111111111.zip
Expected Behavior
dotnet
process exitsActual Behavior
Process locked awaiting something
Analysis
Application deadlocks when output, produced by build goes above some limit. If it doesn't for you - just copy-paste properties in test class to increase amount of errors which will increase amount of printed text.
To workaround issue read output stream immediately instead of waiting for application to exit:
Threads stacks in build process:
Main Thread Pump 1 Pump 2 Node
Versions & Configurations
dotnet --info