Skip to content

Commit

Permalink
Adding timeout to the dotnet info command, using environment variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
phmonte authored and daveaglick committed Dec 19, 2023
1 parent b1cc19c commit 28cb7ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Buildalyzer/Environment/DotnetPathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ private List<string> GetInfo(string projectPath, string dotnetExePath)
// global.json may change the version, so need to set working directory
using (ProcessRunner processRunner = new ProcessRunner(dotnetExePath, "--info", Path.GetDirectoryName(projectPath), environmentVariables, _loggerFactory))
{
int dotnetInfoWaitTime = int.TryParse(System.Environment.GetEnvironmentVariable(EnvironmentVariables.DOTNET_INFO_WAIT_TIME), out int dotnetInfoWaitTimeParsed)
? dotnetInfoWaitTimeParsed
: 4000;
_logger?.LogInformation($"dotnet --info wait time is {dotnetInfoWaitTime}ms");
processRunner.Start();
processRunner.WaitForExit(4000);
processRunner.WaitForExit(dotnetInfoWaitTime);
return processRunner.Output;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Buildalyzer/Environment/EnvironmentVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public static class EnvironmentVariables
public const string MSBUILD_EXE_PATH = nameof(MSBUILD_EXE_PATH);
public const string COREHOST_TRACE = nameof(COREHOST_TRACE);
public const string DOTNET_HOST_PATH = nameof(DOTNET_HOST_PATH);
public const string DOTNET_INFO_WAIT_TIME = nameof(DOTNET_INFO_WAIT_TIME);
#pragma warning restore CA1707
#pragma warning restore SA1310 // Field names should not contain underscore
public const string MSBUILDDISABLENODEREUSE = nameof(MSBUILDDISABLENODEREUSE);
Expand Down

0 comments on commit 28cb7ee

Please sign in to comment.