phmonte / Buildalyzer

A utility to perform design-time builds of .NET projects without having to think too hard about it.
MIT License
606 stars 95 forks source link

Intermittent error "Could not find build environment" #174

Closed lostmsu closed 7 months ago

lostmsu commented 3 years ago

This is the same issue as #125 , except now the problem is dotnet --info sometimes does not make it in 4 seconds (I am running a lot of concurrent analyzers). See hardcoded timeout in https://github.com/daveaglick/Buildalyzer/blob/da88770a2952f7894c05cd0866ef9d766f78aaea/src/Buildalyzer/Environment/DotnetPathResolver.cs#L63

I have 3 options for solving/improving it:

  1. Don't impose a timeout at all in that particular method.
  2. Pass around CancellationToken and let the caller handle timeout conditions.
  3. (incomplete solution) Increase timeout interval or make it configurable.
  4. (incomplete solution) In that particular method, use WaitForExit with timeout in a loop. Continue looping if during the last 4 seconds dotnet --info added some output.

Additionally, it is not clear to me right now why the output of dotnet --info can not be cached after the first run (per dotnet path). Environment variables for that call are hardcoded, and the only thing that's changing is the current directory, which can only affect result in a narrow case: running on Windows (or on *nix with PATH env var containing .), and there's a dotnet.exe next to the project file.

phmonte commented 7 months ago

Hello @lostmsu, An environment variable was created to customize the execution time of the dotnet --info command and the default time was also changed to 10 seconds.

v6.0.0 - Adding the DOTNET_INFO_WAIT_TIME environment variable

v6.0.2 - Changing to 10 seconds.

If the problem still persists, please open a new issue.