private static void ExecuteNuget(FilePath nugetToolPath, string arguments, string fallbackarguments, int retries)
{
while (true)
{
var process = Process.Start(new ProcessStartInfo(nugetToolPath.FullPath, arguments) {UseShellExecute = false});
if (process == null)
{
throw new NullReferenceException(nameof(process));
}
bool timeout;
if ((timeout = !process.WaitForExit(45000)) && !process.HasExited)
{
process.Kill();
}
if (!timeout && process.ExitCode == 0)
{
return;
}
if (--retries <= 0)
{
throw new InvalidOperationException($"Failed to install package ({arguments})");
}
arguments = fallbackarguments;
}
}