in src/DependencyManagement/DependencySnapshotInstaller.cs [123:162]
private void InstallModule(DependencyInfo module, string installingPath, PowerShell pwsh, ILogger logger)
{
logger.Log(isUserOnlyLog: false, LogLevel.Trace, string.Format(PowerShellWorkerStrings.StartedInstallingModule, module.Name, module.ExactVersion));
int tries = 1;
while (true)
{
try
{
var stopwatch = new Stopwatch();
stopwatch.Start();
_moduleProvider.SaveModule(pwsh, module.Name, module.ExactVersion, installingPath);
var message = string.Format(PowerShellWorkerStrings.ModuleHasBeenInstalled, module.Name, module.ExactVersion, stopwatch.ElapsedMilliseconds);
logger.Log(isUserOnlyLog: false, LogLevel.Trace, message);
break;
}
catch (Exception e)
{
string currentAttempt = GetCurrentAttemptMessage(tries);
var errorMsg = string.Format(PowerShellWorkerStrings.FailToInstallModule, module.Name, module.ExactVersion, currentAttempt, e.Message);
logger.Log(isUserOnlyLog: false, LogLevel.Error, errorMsg);
if (tries >= MaxNumberOfTries)
{
errorMsg = string.Format(PowerShellWorkerStrings.FailToInstallFuncAppDependencies, e.Message);
throw new DependencyInstallationException(errorMsg, e);
}
}
// Wait for 2^(tries-1) seconds between retries. In this case, it would be 1, 2, and 4 seconds, respectively.
var waitTimeSpan = TimeSpan.FromSeconds(Math.Pow(2, tries - 1));
Thread.Sleep(waitTimeSpan);
tries++;
}
}