Skip to content

Commit 54abeef

Browse files
authored
Revert "Clean up error experience when downloading non-tools (#43045)" (#43872)
2 parents 5a0344e + 952f719 commit 54abeef

20 files changed

+14
-130
lines changed

src/Cli/dotnet/NugetPackageDownloader/INuGetPackageDownloader.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ Task<string> DownloadPackageAsync(PackageId packageId,
1616
bool includePreview = false,
1717
bool? includeUnlisted = null,
1818
DirectoryPath? downloadFolder = null,
19-
PackageSourceMapping packageSourceMapping = null,
20-
bool isTool = false);
19+
PackageSourceMapping packageSourceMapping = null);
2120

2221
Task<string> GetPackageUrl(PackageId packageId,
2322
NuGetVersion packageVersion = null,

src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@
126126
<data name="IsNotFoundInNuGetFeeds" xml:space="preserve">
127127
<value>{0} is not found in NuGet feeds {1}.</value>
128128
</data>
129-
<data name="NotATool" xml:space="preserve">
130-
<value>Package {0} is not a .NET tool.</value>
131-
</data>
132129
<data name="DownloadVersionFailed" xml:space="preserve">
133130
<value>Downloading {0} version {1} failed.</value>
134131
</data>

src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,45 +83,19 @@ public async Task<string> DownloadPackageAsync(PackageId packageId,
8383
bool includePreview = false,
8484
bool? includeUnlisted = null,
8585
DirectoryPath? downloadFolder = null,
86-
PackageSourceMapping packageSourceMapping = null,
87-
bool isTool = false)
86+
PackageSourceMapping packageSourceMapping = null)
8887
{
8988
CancellationToken cancellationToken = CancellationToken.None;
9089

9190
(var source, var resolvedPackageVersion) = await GetPackageSourceAndVersion(packageId, packageVersion,
9291
packageSourceLocation, includePreview, includeUnlisted ?? packageVersion is not null, packageSourceMapping).ConfigureAwait(false);
9392

93+
FindPackageByIdResource resource = null;
9494
SourceRepository repository = GetSourceRepository(source);
9595

96-
// TODO: Fix this to use the PackageSearchResourceV3 once https://github.com/NuGet/NuGet.Client/pull/5991 is completed.
97-
if (isTool && await repository.GetResourceAsync<ServiceIndexResourceV3>().ConfigureAwait(false) is ServiceIndexResourceV3 serviceIndex)
98-
{
99-
// See https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-manifest-nuspec
100-
var uri = serviceIndex.GetServiceEntries("PackageBaseAddress/3.0.0")[0].Uri;
101-
var queryUri = uri + $"{packageId}/{packageVersion}/{packageId}.nuspec";
102-
103-
using HttpClient client = new(new HttpClientHandler() { CheckCertificateRevocationList = true });
104-
using HttpResponseMessage response = await client.GetAsync(queryUri).ConfigureAwait(false);
105-
106-
if (response.IsSuccessStatusCode)
107-
{
108-
string nuspec = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
109-
110-
XDocument doc = XDocument.Parse(nuspec);
111-
112-
if (!ToolPackageInstance.IsToolPackage(doc))
113-
{
114-
throw new GracefulException(string.Format(LocalizableStrings.NotATool, packageId));
115-
}
116-
}
117-
else
118-
{
119-
throw new GracefulException(string.Format(LocalizableStrings.NotATool, packageId));
120-
}
121-
}
122-
123-
FindPackageByIdResource resource = await repository.GetResourceAsync<FindPackageByIdResource>(cancellationToken)
96+
resource = await repository.GetResourceAsync<FindPackageByIdResource>(cancellationToken)
12497
.ConfigureAwait(false);
98+
12599
if (resource == null)
126100
{
127101
throw new NuGetPackageNotFoundException(

src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.de.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.es.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.it.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)