Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kuhne <jeremy.kuhne@microsoft.com>2015-04-14 23:58:04 +0300
committerJeremy Kuhne <jeremy.kuhne@microsoft.com>2015-04-14 23:58:04 +0300
commitf474b4fc39ba2c4fd3fc23210f1bff85523aebd0 (patch)
tree3b6b5f38699abf68d28f5afe9dc368034fe67368 /dir.targets
parent4970c7488fccce280157bdbbb4c82e87efcef68d (diff)
Change the download task to make three attempts before failing.
Diffstat (limited to 'dir.targets')
-rw-r--r--dir.targets27
1 files changed, 25 insertions, 2 deletions
diff --git a/dir.targets b/dir.targets
index 976cfd29c9..6e3e4d4600 100644
--- a/dir.targets
+++ b/dir.targets
@@ -4,7 +4,7 @@
<!-- Inline task to bootstrap the build to enable downloading nuget.exe -->
<UsingTask TaskName="DownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
- <Address ParameterType="System.String" Required="true"/>
+ <Address ParameterType="System.String" Required="true" />
<FileName ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
@@ -17,7 +17,30 @@
var tempFile = Path.Combine(directory, Path.GetRandomFileName());
var client = new System.Net.WebClient();
- client.DownloadFile(Address, tempFile);
+ var tryCount = 1;
+ var maxTries = 3;
+
+ while (tryCount <= maxTries)
+ {
+ try
+ {
+ Log.LogMessage("Attempting to download {0}...", Address);
+ client.DownloadFile(Address, tempFile);
+ break;
+ }
+ catch (System.Net.WebException e)
+ {
+ tryCount++;
+ if (tryCount > maxTries)
+ {
+ throw;
+ }
+ else
+ {
+ Log.LogMessage(MessageImportance.High, "Download failed, retrying: {0}", e.Message);
+ }
+ }
+ }
try
{