dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.67k stars 1.06k forks source link

"dotnet build" hangs when called from test #42821

Open taori opened 1 month ago

taori commented 1 month ago

Describe the bug

Adding a little context here because it will be needed to understand:

I am developing this: https://github.com/taori/Amusoft.DotnetNew.Tests A project which allows the testing of templates which can be used with dotnet new.

Unfortunately at the stage where i got to testing the execution of dotnet build on the scaffolded project that process will end up hanging in CI (github actions). I tried reproducing the cause of it when running dotnet test on a windows 11 host (my own machine), an ubuntu VM and initially thought that it is in an ubuntu issue, but the first run of the tests on ubuntu VM just took longer ( a couple minutes instead of 15~seconds), then finished just as fast on windows for consecutive runs.

I am unable to figure out why this does not work, but i would be happy if anyone has any ideas.

from a process pov what is happening is: dotnet test is running multiple processes

I went through a couple approaches to try fix it:

note that it works just fine both on ubuntu VM + win11 host.

I am uncertain at this stage on whether the issue is github actions or dotnet build in some way.

If the culprit is github actions i don't understand why it hung on ubuntu VM for the first run for like 15 minutes (that makes it sound like a potential ubuntu issue, which in a CI env could happen loads, since i don't know which build agent i will get) if the culprit is dotnet build - why does it work just fine on my machine, but fails in github actions?

Any pointers to dig deeper myself are welcome, too. I can also provide dumps if that helps.

To Reproduce

gimlichael commented 1 week ago

Seems related: https://github.com/dotnet/core/discussions/9496#discussioncomment-10628380

Did you find a solution to your problem? For me it only happens in GitHub Actions && Ubuntu && .NET9 RC1.

I created an issue here (maybe they are related): https://github.com/dotnet/sdk/issues/43432