From d9d7532bc9d1bf7baa5e387458e898fca8c3e70c Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:03:47 -0400 Subject: [PATCH 01/12] Clean up error experience when downloading non-tools --- .../INuGetPackageDownloader.cs | 3 ++- .../LocalizableStrings.resx | 3 +++ .../NuGetPackageDownloader.cs | 19 +++++++++++++++---- .../xlf/LocalizableStrings.cs.xlf | 5 +++++ .../xlf/LocalizableStrings.de.xlf | 5 +++++ .../xlf/LocalizableStrings.es.xlf | 5 +++++ .../xlf/LocalizableStrings.fr.xlf | 5 +++++ .../xlf/LocalizableStrings.it.xlf | 5 +++++ .../xlf/LocalizableStrings.ja.xlf | 5 +++++ .../xlf/LocalizableStrings.ko.xlf | 5 +++++ .../xlf/LocalizableStrings.pl.xlf | 5 +++++ .../xlf/LocalizableStrings.pt-BR.xlf | 5 +++++ .../xlf/LocalizableStrings.ru.xlf | 5 +++++ .../xlf/LocalizableStrings.tr.xlf | 5 +++++ .../xlf/LocalizableStrings.zh-Hans.xlf | 5 +++++ .../xlf/LocalizableStrings.zh-Hant.xlf | 5 +++++ .../ToolPackage/ToolPackageDownloader.cs | 2 +- .../FailingNuGetPackageInstaller.cs | 3 ++- .../MockNuGetPackageInstaller.cs | 3 ++- 19 files changed, 90 insertions(+), 8 deletions(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/INuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/INuGetPackageDownloader.cs index d2d340ccefb1..62852834de27 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/INuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/INuGetPackageDownloader.cs @@ -16,7 +16,8 @@ Task DownloadPackageAsync(PackageId packageId, bool includePreview = false, bool? includeUnlisted = null, DirectoryPath? downloadFolder = null, - PackageSourceMapping packageSourceMapping = null); + PackageSourceMapping packageSourceMapping = null, + bool isTool = false); Task GetPackageUrl(PackageId packageId, NuGetVersion packageVersion = null, diff --git a/src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx b/src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx index f5e51e2e900d..6d03d607b3bd 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx +++ b/src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx @@ -126,6 +126,9 @@ {0} is not found in NuGet feeds {1}. + + Package {0} is not a dotnet tool. + Downloading {0} version {1} failed. diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index c1c4d9318862..c687251e1209 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -83,19 +83,30 @@ public async Task DownloadPackageAsync(PackageId packageId, bool includePreview = false, bool? includeUnlisted = null, DirectoryPath? downloadFolder = null, - PackageSourceMapping packageSourceMapping = null) + PackageSourceMapping packageSourceMapping = null, + bool isTool = false) { CancellationToken cancellationToken = CancellationToken.None; (var source, var resolvedPackageVersion) = await GetPackageSourceAndVersion(packageId, packageVersion, packageSourceLocation, includePreview, includeUnlisted ?? packageVersion is not null, packageSourceMapping).ConfigureAwait(false); - FindPackageByIdResource resource = null; SourceRepository repository = GetSourceRepository(source); - resource = await repository.GetResourceAsync(cancellationToken) - .ConfigureAwait(false); + if (isTool && await repository.GetResourceAsync().ConfigureAwait(false) is ServiceIndexResourceV3 serviceIndex) + { + var uri = serviceIndex.GetServiceEntries("SearchQueryService/3.5.0")[0].Uri; + var queryUri = uri + $"?q={packageId}&packageType=dotnettool"; + using HttpClient client = new(new HttpClientHandler() { CheckCertificateRevocationList = true }); + using HttpResponseMessage response = await client.GetAsync(queryUri).ConfigureAwait(false); + if (response.Content.Headers.ContentLength == 139) + { + throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); + } + } + FindPackageByIdResource resource = await repository.GetResourceAsync(cancellationToken) + .ConfigureAwait(false); if (resource == null) { throw new NuGetPackageNotFoundException( diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf index b8746dd50ae4..f5c52ca48bc7 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf @@ -37,6 +37,11 @@ Balíček {0} se nenašel v informačních kanálech NuGet {1}. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. Přeskakuje se ověření podpisu balíčku NuGet. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.de.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.de.xlf index d7f2feaee60f..9817364dbf95 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.de.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.de.xlf @@ -37,6 +37,11 @@ "{0}" wurde in NuGet-Feeds "{1}" nicht gefunden. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. Die Überprüfung der NuGet-Paketsignatur wird übersprungen. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.es.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.es.xlf index 8f7665c41707..07a9fc205a8c 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.es.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.es.xlf @@ -37,6 +37,11 @@ No se encuentra {0} en las fuentes de NuGet {1}. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. Omitiendo la comprobación de la firma del paquete NuGet. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf index 371e037ff4cb..29d695372f73 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf @@ -37,6 +37,11 @@ {0} est introuvable dans les flux NuGet {1}. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. La vérification de la signature du package NuGet est ignorée. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.it.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.it.xlf index 49643fd5d074..cbb2f92b5446 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.it.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.it.xlf @@ -37,6 +37,11 @@ {0} non è stato trovato nei feed NuGet {1}. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. La verifica della firma del pacchetto NuGet verrà ignorata. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf index 0471c7d97648..e6227ef9f99c 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf @@ -37,6 +37,11 @@ {0} が NuGet フィード {1} に見つかりません。 + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. NuGet パッケージ署名の認証をスキップしています。 diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf index 5a17478c9016..f71d141631c4 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf @@ -37,6 +37,11 @@ NuGet 피드 {1} 에서 {0}을(를) 찾을 수 없습니다. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. NuGet 패키지 서명 확인을 건너뛰는 중입니다. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pl.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pl.xlf index daa713f0e271..f48a401177c4 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pl.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pl.xlf @@ -37,6 +37,11 @@ Nie znaleziono pakietu {0} w kanałach informacyjnych NuGet {1}. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. Pomijanie weryfikacji podpisu pakietu NuGet. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pt-BR.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pt-BR.xlf index eccae44c1a30..1ab1cb034cd4 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pt-BR.xlf @@ -37,6 +37,11 @@ {0} não foi encontrado no NuGet feeds {1}. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. Ignorando a verificação de assinatura do pacote NuGet. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ru.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ru.xlf index 0bf016d6bd56..a866e9ea33cb 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ru.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ru.xlf @@ -37,6 +37,11 @@ {0} не найдено в веб-каналах NuGet {1}. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. Пропуск проверки подписи пакета NuGet. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.tr.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.tr.xlf index 4e8dc04150e3..a91464f20e8a 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.tr.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.tr.xlf @@ -37,6 +37,11 @@ {0}, {1} NuGet akışlarında bulunamadı. + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. NuGet paket imzası doğrulaması atlanıyor. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hans.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hans.xlf index f7303342d2a0..340710dc006c 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hans.xlf @@ -37,6 +37,11 @@ 在 NuGet 源 {1} 中找不到 {0}。 + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. 正在跳过 NuGet 包签名验证。 diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hant.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hant.xlf index 37eece9cf07e..395a969f13af 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hant.xlf @@ -37,6 +37,11 @@ 在 NuGet 摘要 {1} 中找不到 {0}"。 + + Package {0} is not a dotnet tool. + Package {0} is not a dotnet tool. + + Skipping NuGet package signature verification. 正在略過 NuGet 套件簽章驗證。 diff --git a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs index 84d07f2eef12..d295ac6fc151 100644 --- a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs +++ b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs @@ -284,7 +284,7 @@ private static async Task DownloadAndExtractPackage( bool includeUnlisted = false ) { - var packagePath = await nugetPackageDownloader.DownloadPackageAsync(packageId, packageVersion, packageSourceLocation, includeUnlisted: includeUnlisted).ConfigureAwait(false); + var packagePath = await nugetPackageDownloader.DownloadPackageAsync(packageId, packageVersion, packageSourceLocation, includeUnlisted: includeUnlisted, isTool: true).ConfigureAwait(false); // look for package on disk and read the version NuGetVersion version; diff --git a/test/dotnet-workload-install.Tests/FailingNuGetPackageInstaller.cs b/test/dotnet-workload-install.Tests/FailingNuGetPackageInstaller.cs index 6f10a82923e5..9906e45e7af3 100644 --- a/test/dotnet-workload-install.Tests/FailingNuGetPackageInstaller.cs +++ b/test/dotnet-workload-install.Tests/FailingNuGetPackageInstaller.cs @@ -23,7 +23,8 @@ public Task DownloadPackageAsync(PackageId packageId, NuGetVersion packa bool includePreview = false, bool? includeUnlisted = null, DirectoryPath? downloadFolder = null, - PackageSourceMapping packageSourceMapping = null) + PackageSourceMapping packageSourceMapping = null, + bool isTool = false) { var mockPackagePath = Path.Combine(MockPackageDir, $"{packageId}.{packageVersion}.nupkg"); File.WriteAllText(mockPackagePath, string.Empty); diff --git a/test/dotnet-workload-install.Tests/MockNuGetPackageInstaller.cs b/test/dotnet-workload-install.Tests/MockNuGetPackageInstaller.cs index 84c60802bd1d..ea2be4215582 100644 --- a/test/dotnet-workload-install.Tests/MockNuGetPackageInstaller.cs +++ b/test/dotnet-workload-install.Tests/MockNuGetPackageInstaller.cs @@ -38,7 +38,8 @@ public Task DownloadPackageAsync(PackageId packageId, bool includePreview = false, bool? includeUnlisted = null, DirectoryPath? downloadFolder = null, - PackageSourceMapping packageSourceMapping = null) + PackageSourceMapping packageSourceMapping = null, + bool isTool = false) { DownloadCallParams.Add((packageId, packageVersion, downloadFolder, packageSourceLocation)); From 707519330774ab5b44229f34789b5c66d9c1b9d9 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:30:21 -0700 Subject: [PATCH 02/12] Update src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs Co-authored-by: Chet Husk --- .../NugetPackageDownloader/NuGetPackageDownloader.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index c687251e1209..766d1b305147 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -93,13 +93,13 @@ public async Task DownloadPackageAsync(PackageId packageId, SourceRepository repository = GetSourceRepository(source); - if (isTool && await repository.GetResourceAsync().ConfigureAwait(false) is ServiceIndexResourceV3 serviceIndex) + if (isTool && await repository.GetResourceAsync(cancellationToken).ConfigureAwait(false) is var searchResource) { - var uri = serviceIndex.GetServiceEntries("SearchQueryService/3.5.0")[0].Uri; - var queryUri = uri + $"?q={packageId}&packageType=dotnettool"; - using HttpClient client = new(new HttpClientHandler() { CheckCertificateRevocationList = true }); - using HttpResponseMessage response = await client.GetAsync(queryUri).ConfigureAwait(false); - if (response.Content.Headers.ContentLength == 139) + var results = await searchResource.SearchAsync(packageId.ToString(), new SearchFilter(includePrerelease: includePreview, filter: SearchFilterType.IsLatestVersion) + { + PackageTypes = [NuGet.Packaging.Core.PackageType.DotnetTool.Name] + }, skip: 0, take: 10, log: _verboseLogger, cancellationToken: cancellationToken).ConfigureAwait(false); + if (results.Count() == 0) { throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); } From ac56ea84e1150b55fc57c41cb6fec865dd4af518 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:33:01 -0400 Subject: [PATCH 03/12] Small tweak --- .../dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index 766d1b305147..4a8897cc5aa9 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -93,13 +93,14 @@ public async Task DownloadPackageAsync(PackageId packageId, SourceRepository repository = GetSourceRepository(source); - if (isTool && await repository.GetResourceAsync(cancellationToken).ConfigureAwait(false) is var searchResource) + if (isTool && await repository.GetResourceAsync(cancellationToken).ConfigureAwait(false) is var searchResource) { var results = await searchResource.SearchAsync(packageId.ToString(), new SearchFilter(includePrerelease: includePreview, filter: SearchFilterType.IsLatestVersion) { PackageTypes = [NuGet.Packaging.Core.PackageType.DotnetTool.Name] }, skip: 0, take: 10, log: _verboseLogger, cancellationToken: cancellationToken).ConfigureAwait(false); - if (results.Count() == 0) + + if (!results.Any()) { throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); } From 0ad3fb974894a15db8ef2d551951388b7a1e916f Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:22:48 -0400 Subject: [PATCH 04/12] Prevent NRE --- src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index 4a8897cc5aa9..fa956b9974a6 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -93,7 +93,7 @@ public async Task DownloadPackageAsync(PackageId packageId, SourceRepository repository = GetSourceRepository(source); - if (isTool && await repository.GetResourceAsync(cancellationToken).ConfigureAwait(false) is var searchResource) + if (isTool && await repository.GetResourceAsync(cancellationToken).ConfigureAwait(false) is PackageSearchResourceV3 searchResource) { var results = await searchResource.SearchAsync(packageId.ToString(), new SearchFilter(includePrerelease: includePreview, filter: SearchFilterType.IsLatestVersion) { From 1c76fd7abaa73fde541eda5d76da1f61ef62a9ed Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Thu, 29 Aug 2024 18:44:18 -0400 Subject: [PATCH 05/12] Switch to not showing full exception --- src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index fa956b9974a6..ec89d9c0b5d0 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -102,7 +102,7 @@ public async Task DownloadPackageAsync(PackageId packageId, if (!results.Any()) { - throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); + throw new GracefulException(string.Format(LocalizableStrings.NotATool, packageId)); } } From c5f40d75ba7a4504f2158074f5507b1b46ad1120 Mon Sep 17 00:00:00 2001 From: Jacques Eloff Date: Tue, 3 Sep 2024 21:25:48 -0700 Subject: [PATCH 06/12] Update error message --- src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx | 2 +- .../NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.de.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.es.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.it.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.pl.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.pt-BR.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.ru.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.tr.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.zh-Hans.xlf | 4 ++-- .../NugetPackageDownloader/xlf/LocalizableStrings.zh-Hant.xlf | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx b/src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx index 6d03d607b3bd..fd22df9f371a 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx +++ b/src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx @@ -127,7 +127,7 @@ {0} is not found in NuGet feeds {1}. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. Downloading {0} version {1} failed. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf index f5c52ca48bc7..3480a5e9bf8b 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.cs.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.de.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.de.xlf index 9817364dbf95..0fac6d8582b4 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.de.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.de.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.es.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.es.xlf index 07a9fc205a8c..0bc2862f84b8 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.es.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.es.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf index 29d695372f73..7b3151f742d7 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.fr.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.it.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.it.xlf index cbb2f92b5446..6c62d8290b43 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.it.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.it.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf index e6227ef9f99c..90b352e1cb3c 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ja.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf index f71d141631c4..748ddbf713e5 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ko.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pl.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pl.xlf index f48a401177c4..ee5caf8ab2a0 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pl.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pl.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pt-BR.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pt-BR.xlf index 1ab1cb034cd4..49bcdfa31490 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.pt-BR.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ru.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ru.xlf index a866e9ea33cb..fd39c2082e1c 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ru.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.ru.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.tr.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.tr.xlf index a91464f20e8a..f14f6c3ad5d0 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.tr.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.tr.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hans.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hans.xlf index 340710dc006c..d5c7630d016b 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hans.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. diff --git a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hant.xlf b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hant.xlf index 395a969f13af..40e880e4c730 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/NugetPackageDownloader/xlf/LocalizableStrings.zh-Hant.xlf @@ -38,8 +38,8 @@ - Package {0} is not a dotnet tool. - Package {0} is not a dotnet tool. + Package {0} is not a .NET tool. + Package {0} is not a .NET tool. From a97488b1a681875a5194fae24567e87287196667 Mon Sep 17 00:00:00 2001 From: Jacques Eloff Date: Thu, 5 Sep 2024 14:29:09 -0700 Subject: [PATCH 07/12] Temporary workaround for failing tests --- test/dotnet-new.Tests/CommonTemplatesTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/dotnet-new.Tests/CommonTemplatesTests.cs b/test/dotnet-new.Tests/CommonTemplatesTests.cs index 6f598250a7ef..af3e123dc1d5 100644 --- a/test/dotnet-new.Tests/CommonTemplatesTests.cs +++ b/test/dotnet-new.Tests/CommonTemplatesTests.cs @@ -12,6 +12,8 @@ namespace Microsoft.DotNet.Cli.New.IntegrationTests { + // Temporary workaround for possible threading issues related to accessing VS COM objects. + [Collection("C1")] public class CommonTemplatesTests : BaseIntegrationTest, IClassFixture { private readonly SharedHomeDirectory _fixture; From 35c48825888c5139f08505f9232d081458905601 Mon Sep 17 00:00:00 2001 From: Jacques Eloff Date: Mon, 9 Sep 2024 09:08:07 -0700 Subject: [PATCH 08/12] Remove work-around for test failures --- test/dotnet-new.Tests/CommonTemplatesTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/dotnet-new.Tests/CommonTemplatesTests.cs b/test/dotnet-new.Tests/CommonTemplatesTests.cs index af3e123dc1d5..6f598250a7ef 100644 --- a/test/dotnet-new.Tests/CommonTemplatesTests.cs +++ b/test/dotnet-new.Tests/CommonTemplatesTests.cs @@ -12,8 +12,6 @@ namespace Microsoft.DotNet.Cli.New.IntegrationTests { - // Temporary workaround for possible threading issues related to accessing VS COM objects. - [Collection("C1")] public class CommonTemplatesTests : BaseIntegrationTest, IClassFixture { private readonly SharedHomeDirectory _fixture; From 9aa72b3e60a44c8af17dabc9caafc56daa6a3f9c Mon Sep 17 00:00:00 2001 From: Jacques Eloff Date: Mon, 9 Sep 2024 15:11:17 -0700 Subject: [PATCH 09/12] Read packageType from nuspec using REST API --- .../NuGetPackageDownloader.cs | 47 ++++++++++++++++--- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index ec89d9c0b5d0..a4eafe3e522f 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -93,19 +93,52 @@ public async Task DownloadPackageAsync(PackageId packageId, SourceRepository repository = GetSourceRepository(source); - if (isTool && await repository.GetResourceAsync(cancellationToken).ConfigureAwait(false) is PackageSearchResourceV3 searchResource) + if (isTool && await repository.GetResourceAsync().ConfigureAwait(false) is ServiceIndexResourceV3 serviceIndex) { - var results = await searchResource.SearchAsync(packageId.ToString(), new SearchFilter(includePrerelease: includePreview, filter: SearchFilterType.IsLatestVersion) - { - PackageTypes = [NuGet.Packaging.Core.PackageType.DotnetTool.Name] - }, skip: 0, take: 10, log: _verboseLogger, cancellationToken: cancellationToken).ConfigureAwait(false); + // TODO: Fix this to use the PackageSearchResourceV3 once https://github.com/NuGet/NuGet.Client/pull/5991 is completed. + var uri = serviceIndex.GetServiceEntries("PackageBaseAddress/3.0.0")[0].Uri; + var queryUri = uri + $"{packageId}/{packageVersion}/{packageId}.nuspec"; + + using HttpClient client = new(new HttpClientHandler() { CheckCertificateRevocationList = true }); + using HttpResponseMessage response = await client.GetAsync(queryUri).ConfigureAwait(false); - if (!results.Any()) + if (response.IsSuccessStatusCode) { - throw new GracefulException(string.Format(LocalizableStrings.NotATool, packageId)); + string nuspec = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + + try + { + XDocument doc = XDocument.Parse(nuspec); + + if (!doc.Root.Descendants().Where(e => e.Name.LocalName == "packageType" && + e.Attributes().Where(a => a.Name.LocalName == "name" && a.Value == "DotnetTool").Any()).Any() { + + } + } } + + + + throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); } + + + + //if (isTool && await repository.GetResourceAsync(cancellationToken).ConfigureAwait(false) is var metadataResource) + //{ + // var cacheContext = new SourceCacheContext { NoCache = true, DirectDownload = true }; + + // var results = await metadataResource.GetMetadataAsync(packageId.ToString(), includePreview, includeUnlisted ?? false, cacheContext, _verboseLogger, cancellationToken) + // .ConfigureAwait(false); + + // if (results.Count() == 0) + // { + // results.First().C + // throw new GracefulException(string.Format(LocalizableStrings.NotATool, packageId)); + // } + //} + FindPackageByIdResource resource = await repository.GetResourceAsync(cancellationToken) .ConfigureAwait(false); if (resource == null) From 3ba916b2dca4fe9a84ac35644b7a0cb99e1b3787 Mon Sep 17 00:00:00 2001 From: Jacques Eloff Date: Mon, 9 Sep 2024 15:13:40 -0700 Subject: [PATCH 10/12] Fix stale copy of the downloader --- .../NuGetPackageDownloader.cs | 41 ++++++------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index a4eafe3e522f..7e6c029c72dd 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -93,9 +93,10 @@ public async Task DownloadPackageAsync(PackageId packageId, SourceRepository repository = GetSourceRepository(source); + // TODO: Fix this to use the PackageSearchResourceV3 once https://github.com/NuGet/NuGet.Client/pull/5991 is completed. if (isTool && await repository.GetResourceAsync().ConfigureAwait(false) is ServiceIndexResourceV3 serviceIndex) { - // TODO: Fix this to use the PackageSearchResourceV3 once https://github.com/NuGet/NuGet.Client/pull/5991 is completed. + // See https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-manifest-nuspec var uri = serviceIndex.GetServiceEntries("PackageBaseAddress/3.0.0")[0].Uri; var queryUri = uri + $"{packageId}/{packageVersion}/{packageId}.nuspec"; @@ -106,39 +107,21 @@ public async Task DownloadPackageAsync(PackageId packageId, { string nuspec = await response.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - XDocument doc = XDocument.Parse(nuspec); - - if (!doc.Root.Descendants().Where(e => e.Name.LocalName == "packageType" && - e.Attributes().Where(a => a.Name.LocalName == "name" && a.Value == "DotnetTool").Any()).Any() { + XDocument doc = XDocument.Parse(nuspec); - } + if (!doc.Root.Descendants().Where( + e => e.Name.LocalName == "packageType" && + e.Attributes().Where(a => a.Name.LocalName == "name" && a.Value == "DotnetTool").Any()).Any()) + { + throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); } } - - - - throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); + else + { + throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); + } } - - - - //if (isTool && await repository.GetResourceAsync(cancellationToken).ConfigureAwait(false) is var metadataResource) - //{ - // var cacheContext = new SourceCacheContext { NoCache = true, DirectDownload = true }; - - // var results = await metadataResource.GetMetadataAsync(packageId.ToString(), includePreview, includeUnlisted ?? false, cacheContext, _verboseLogger, cancellationToken) - // .ConfigureAwait(false); - - // if (results.Count() == 0) - // { - // results.First().C - // throw new GracefulException(string.Format(LocalizableStrings.NotATool, packageId)); - // } - //} - FindPackageByIdResource resource = await repository.GetResourceAsync(cancellationToken) .ConfigureAwait(false); if (resource == null) From 65e2ef3bfc5ffaf452379fadca04b216d7b3cc1c Mon Sep 17 00:00:00 2001 From: Jacques Eloff Date: Mon, 9 Sep 2024 16:33:37 -0700 Subject: [PATCH 11/12] Add additional check before creating ToolPackageInstance --- .../NuGetPackageDownloader.cs | 4 +--- .../ToolPackage/ToolPackageDownloader.cs | 20 +++++++++++++------ .../dotnet/ToolPackage/ToolPackageInstance.cs | 11 ++++++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index 7e6c029c72dd..610725d3efde 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -109,9 +109,7 @@ public async Task DownloadPackageAsync(PackageId packageId, XDocument doc = XDocument.Parse(nuspec); - if (!doc.Root.Descendants().Where( - e => e.Name.LocalName == "packageType" && - e.Attributes().Where(a => a.Name.LocalName == "name" && a.Value == "DotnetTool").Any()).Any()) + if (!ToolPackageInstance.IsToolPackage(doc)) { throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); } diff --git a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs index d295ac6fc151..865f744d1950 100644 --- a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs +++ b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs @@ -134,13 +134,21 @@ public IToolPackage InstallPackage(PackageLocation packageLocation, PackageId pa { DownloadAndExtractPackage(packageId, nugetPackageDownloader, toolDownloadDir.Value, packageVersion, packageSourceLocation, includeUnlisted: givenSpecificVersion).GetAwaiter().GetResult(); } - else if(isGlobalTool) + else { - throw new ToolPackageException( - string.Format( - CommonLocalizableStrings.ToolPackageConflictPackageId, - packageId, - packageVersion.ToNormalizedString())); + if (!ToolPackageInstance.IsToolPackage(package.Nuspec.Xml)) + { + throw new ToolPackageException(string.Format(NuGetPackageDownloader.LocalizableStrings.NotATool, packageId)); + } + + if (isGlobalTool) + { + throw new ToolPackageException( + string.Format( + CommonLocalizableStrings.ToolPackageConflictPackageId, + packageId, + packageVersion.ToNormalizedString())); + } } CreateAssetFile(packageId, packageVersion, toolDownloadDir, assetFileDirectory, _runtimeJsonPath, targetFramework); diff --git a/src/Cli/dotnet/ToolPackage/ToolPackageInstance.cs b/src/Cli/dotnet/ToolPackage/ToolPackageInstance.cs index f026f370567e..d9ced1ecb703 100644 --- a/src/Cli/dotnet/ToolPackage/ToolPackageInstance.cs +++ b/src/Cli/dotnet/ToolPackage/ToolPackageInstance.cs @@ -23,6 +23,17 @@ public static ToolPackageInstance CreateFromAssetFile(PackageId id, DirectoryPat return new ToolPackageInstance(id, version, packageDirectory, assetsJsonParentDirectory); } + + /// + /// Validates that the nuspec XML represents a .NET tool package. + /// + /// The nuspec XML to check. + /// if the nuspec represents a .NET tool package; otherwise, . + public static bool IsToolPackage(XDocument nuspec) => + nuspec.Root.Descendants().Where( + e => e.Name.LocalName == "packageType" && + e.Attributes().Where(a => a.Name.LocalName == "name" && a.Value == "DotnetTool").Any()).Any(); + private const string PackagedShimsDirectoryConvention = "shims"; public IEnumerable Warnings => _toolConfiguration.Value.Warnings; From aed512a83128531fc3e3ca18fd713f7894469710 Mon Sep 17 00:00:00 2001 From: Jacques Eloff Date: Mon, 16 Sep 2024 12:44:08 -0700 Subject: [PATCH 12/12] Use Graceful exception to only report the error --- .../dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs | 4 ++-- src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index 610725d3efde..4c1176656a8e 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -111,12 +111,12 @@ public async Task DownloadPackageAsync(PackageId packageId, if (!ToolPackageInstance.IsToolPackage(doc)) { - throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); + throw new GracefulException(string.Format(LocalizableStrings.NotATool, packageId)); } } else { - throw new ToolPackageException(string.Format(LocalizableStrings.NotATool, packageId)); + throw new GracefulException(string.Format(LocalizableStrings.NotATool, packageId)); } } diff --git a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs index 865f744d1950..05af9e43115d 100644 --- a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs +++ b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs @@ -138,7 +138,7 @@ public IToolPackage InstallPackage(PackageLocation packageLocation, PackageId pa { if (!ToolPackageInstance.IsToolPackage(package.Nuspec.Xml)) { - throw new ToolPackageException(string.Format(NuGetPackageDownloader.LocalizableStrings.NotATool, packageId)); + throw new GracefulException(string.Format(NuGetPackageDownloader.LocalizableStrings.NotATool, packageId)); } if (isGlobalTool)