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

github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Mitchell <mmitche@microsoft.com>2022-11-09 22:55:14 +0300
committerMatt Mitchell <mmitche@microsoft.com>2022-11-09 22:55:14 +0300
commit3e22a24c882e0c772528345af385715f53ebc5ff (patch)
tree534fdb63e55afe3d4924d1766245bca4877931e8
parent2ebaa4c3f08dc38969dfcd98b8d6f7afb3772d11 (diff)
Use arcade download task and also check dotnetcli
-rw-r--r--eng/Versions.props6
-rw-r--r--eng/tools/RepoTasks/DownloadFile.cs148
-rw-r--r--eng/tools/RepoTasks/RepoTasks.tasks1
-rw-r--r--src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj22
4 files changed, 15 insertions, 162 deletions
diff --git a/eng/Versions.props b/eng/Versions.props
index 519995cf6a..033c88ceac 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -297,10 +297,4 @@
<DotnetServeVersion>1.10.93</DotnetServeVersion>
<MicrosoftPlaywrightCLIVersion>1.2.3</MicrosoftPlaywrightCLIVersion>
</PropertyGroup>
- <!-- Restore feeds -->
- <PropertyGroup Label="Restore feeds">
- <!-- In an orchestrated build, this may be overridden to other Azure feeds. -->
- <DotNetAssetRootUrl Condition="'$(DotNetAssetRootUrl)'==''">https://dotnetbuilds.azureedge.net/public/</DotNetAssetRootUrl>
- <DotNetPrivateAssetRootUrl Condition="'$(DotNetPrivateAssetRootUrl)'==''">https://dotnetbuilds.azureedge.net/internal/</DotNetPrivateAssetRootUrl>
- </PropertyGroup>
</Project>
diff --git a/eng/tools/RepoTasks/DownloadFile.cs b/eng/tools/RepoTasks/DownloadFile.cs
deleted file mode 100644
index 7174fdae60..0000000000
--- a/eng/tools/RepoTasks/DownloadFile.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Microsoft.Build.Framework;
-using Microsoft.Build.Utilities;
-
-namespace RepoTasks;
-
-public class DownloadFile : Microsoft.Build.Utilities.Task
-{
- [Required]
- public string Uri { get; set; }
-
- /// <summary>
- /// If this field is set and the task fail to download the file from `Uri`, with a NotFound
- /// status, it will try to download the file from `PrivateUri`.
- /// </summary>
- public string PrivateUri { get; set; }
-
- /// <summary>
- /// Suffix for the private URI in base64 form (for SAS compatibility)
- /// </summary>
- public string PrivateUriSuffix { get; set; }
-
- public int MaxRetries { get; set; } = 5;
-
- [Required]
- public string DestinationPath { get; set; }
-
- public bool Overwrite { get; set; }
-
- public override bool Execute()
- {
- return ExecuteAsync().GetAwaiter().GetResult();
- }
-
- private async System.Threading.Tasks.Task<bool> ExecuteAsync()
- {
- string destinationDir = Path.GetDirectoryName(DestinationPath);
- if (!Directory.Exists(destinationDir))
- {
- Directory.CreateDirectory(destinationDir);
- }
-
- if (File.Exists(DestinationPath) && !Overwrite)
- {
- return true;
- }
-
- const string FileUriProtocol = "file://";
-
- if (Uri.StartsWith(FileUriProtocol, StringComparison.Ordinal))
- {
- var filePath = Uri.Substring(FileUriProtocol.Length);
- Log.LogMessage($"Copying '{filePath}' to '{DestinationPath}'");
- File.Copy(filePath, DestinationPath);
- return true;
- }
-
- List<string> errorMessages = new List<string>();
- bool? downloadStatus = await DownloadWithRetriesAsync(Uri, DestinationPath, errorMessages);
-
- if (downloadStatus == false && !string.IsNullOrEmpty(PrivateUri))
- {
- string uriSuffix = "";
- if (!string.IsNullOrEmpty(PrivateUriSuffix))
- {
- var uriSuffixBytes = System.Convert.FromBase64String(PrivateUriSuffix);
- uriSuffix = System.Text.Encoding.UTF8.GetString(uriSuffixBytes);
- }
- downloadStatus = await DownloadWithRetriesAsync($"{PrivateUri}{uriSuffix}", DestinationPath, errorMessages);
- }
-
- if (downloadStatus != true)
- {
- foreach (var error in errorMessages)
- {
- Log.LogError(error);
- }
- }
-
- return downloadStatus == true;
- }
-
- /// <summary>
- /// Attempt to download file from `source` with retries when response error is different of FileNotFound and Success.
- /// </summary>
- /// <param name="source">URL to the file to be downloaded.</param>
- /// <param name="target">Local path where to put the downloaded file.</param>
- /// <returns>true: Download Succeeded. false: Download failed with 404. null: Download failed but is retriable.</returns>
- private async Task<bool?> DownloadWithRetriesAsync(string source, string target, List<string> errorMessages)
- {
- Random rng = new Random();
-
- Log.LogMessage(MessageImportance.High, $"Attempting download '{source}' to '{target}'");
-
- using (var httpClient = new HttpClient { Timeout = TimeSpan.FromMinutes(7.5) })
- {
- for (int retryNumber = 0; retryNumber < MaxRetries; retryNumber++)
- {
- try
- {
- var httpResponse = await httpClient.GetAsync(source);
-
- Log.LogMessage(MessageImportance.High, $"{source} -> {httpResponse.StatusCode}");
-
- // The Azure Storage REST API returns '400 - Bad Request' in some cases
- // where the resource is not found on the storage.
- // https://docs.microsoft.com/en-us/rest/api/storageservices/common-rest-api-error-codes
- if (httpResponse.StatusCode == HttpStatusCode.NotFound ||
- httpResponse.ReasonPhrase.IndexOf("The requested URI does not represent any resource on the server.", StringComparison.OrdinalIgnoreCase) == 0)
- {
- errorMessages.Add($"Problems downloading file from '{source}'. Does the resource exist on the storage? {httpResponse.StatusCode} : {httpResponse.ReasonPhrase}");
- return false;
- }
-
- httpResponse.EnsureSuccessStatusCode();
-
- using (var outStream = File.Create(target))
- {
- await httpResponse.Content.CopyToAsync(outStream);
- }
-
- Log.LogMessage(MessageImportance.High, $"returning true {source} -> {httpResponse.StatusCode}");
- return true;
- }
- catch (Exception e)
- {
- Log.LogMessage(MessageImportance.High, $"returning error in {source} ");
- errorMessages.Add($"Problems downloading file from '{source}'. {e.Message} {e.StackTrace}");
- File.Delete(target);
- }
-
- await System.Threading.Tasks.Task.Delay(rng.Next(1000, 10000));
- }
- }
-
- Log.LogMessage(MessageImportance.High, $"giving up {source} ");
- errorMessages.Add($"Giving up downloading the file from '{source}' after {MaxRetries} retries.");
- return null;
- }
-}
diff --git a/eng/tools/RepoTasks/RepoTasks.tasks b/eng/tools/RepoTasks/RepoTasks.tasks
index 788558c3fa..94db734ffb 100644
--- a/eng/tools/RepoTasks/RepoTasks.tasks
+++ b/eng/tools/RepoTasks/RepoTasks.tasks
@@ -10,5 +10,4 @@
<UsingTask TaskName="RepoTasks.GenerateSharedFrameworkDepsFile" AssemblyFile="$(_RepoTaskAssembly)" />
<UsingTask TaskName="RepoTasks.CreateFrameworkListFile" AssemblyFile="$(_RepoTaskAssembly)" />
<UsingTask TaskName="RepoTasks.RemoveSharedFrameworkDependencies" AssemblyFile="$(_RepoTaskAssembly)" />
- <UsingTask TaskName="RepoTasks.DownloadFile" AssemblyFile="$(_RepoTaskAssembly)" />
</Project>
diff --git a/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
index bf90848a34..e8d47b02c2 100644
--- a/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
+++ b/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
@@ -32,8 +32,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
<!-- Use the BrowserDebugHost as a sentinel for the nonshipping version for .NETCoreApp -->
<DotNetRuntimeArchiveFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-$(TargetRuntimeIdentifier)$(ArchiveExtension)</DotNetRuntimeArchiveFileName>
- <DotNetRuntimeDownloadUrl>$(DotNetAssetRootUrl)Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/$(DotNetRuntimeArchiveFileName)</DotNetRuntimeDownloadUrl>
- <DotNetRuntimePrivateDownloadUrl>$(DotNetPrivateAssetRootUrl)Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/$(DotNetRuntimeArchiveFileName)</DotNetRuntimePrivateDownloadUrl>
+ <DotNetRuntimeDownloadPath>Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/$(DotNetRuntimeArchiveFileName)</DotNetRuntimeDownloadPath>
<DotNetRuntimeArchive>$(BaseIntermediateOutputPath)$(DotNetRuntimeArchiveFileName)</DotNetRuntimeArchive>
<!-- Setting this suppresses getting documentation .xml files in the shared runtime output. -->
@@ -502,11 +501,20 @@ This package is an internal implementation of the .NET Core SDK and is not meant
#########################################
-->
<Target Name="_DownloadAndExtractDotNetRuntime" Condition="'$(DotNetBuildFromSource)' != 'true'">
- <DownloadFile Condition=" ! Exists('$(DotNetRuntimeArchive)')"
- Uri="$(DotNetRuntimeDownloadUrl)"
- PrivateUri="$(DotNetRuntimePrivateDownloadUrl)"
- PrivateUriSuffix="$(DotNetAssetRootAccessTokenSuffix)"
- DestinationPath="$(DotNetRuntimeArchive)" />
+ <!-- Try various places to find the runtime. It's either released (use official version),
+ public but un-released (use dotnetbuilds/public), or internal and unreleased (use dotnetbuilds/internal) -->
+ <ItemGroup>
+ <UrisToDownload Include="https://dotnetcli.azureedge.net/dotnet/$(DotNetRuntimeDownloadPath)" />
+ <UrisToDownload Include="https://dotnetbuilds.azureedge.net/public/$(DotNetRuntimeDownloadPath)" />
+ <UrisToDownload Include="https://dotnetbuilds.azureedge.net/internal/$(DotNetRuntimeDownloadPath)">
+ <token>$(DotnetRuntimeSourceFeedKey)</token>
+ </UrisToDownload>
+ </ItemGroup>
+
+ <DownloadFile Condition=" !Exists('$(DotNetRuntimeArchive)') "
+ Uris="@(UrisToDownload)"
+ DestinationPath="%(DotNetRuntimeArchive)" />
+
<RemoveDir Directories="$(RedistSharedFrameworkLayoutRoot)" />
<MakeDir Directories="$(RedistSharedFrameworkLayoutRoot)" />