Skip to content

Commit 7bd2e43

Browse files
committed
block not mapped source
1 parent f9f62b7 commit 7bd2e43

17 files changed

Lines changed: 127 additions & 30 deletions

File tree

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Download/PackageDownloadRunner.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,25 @@ public static async Task<int> RunAsync(PackageDownloadArgs args, ILoggerWithColo
9292
else
9393
{
9494
var mappedNames = packageSourceMapping!.GetConfiguredPackageSources(package.Id);
95-
sourceRepositories = mappedNames.Count > 0
96-
? GetMappedRepositories(mappedNames, allRepositories, package.Id, logger)
97-
: allRepositories;
95+
96+
if (mappedNames.Count == 0)
97+
{
98+
// fail, no sources mapped for this package
99+
var notConsideredSources = string.Join(
100+
", ",
101+
allRepositories.Select(repository => repository.PackageSource));
102+
103+
logger.LogError(string.Format(
104+
CultureInfo.CurrentCulture,
105+
Strings.PackageDownloadCommand_PackageSourceMapping_NoSourcesMapped,
106+
package.Id,
107+
notConsideredSources));
108+
109+
downloadedAllSuccessfully &= false;
110+
continue;
111+
}
112+
113+
sourceRepositories = GetMappedRepositories(mappedNames, allRepositories, package.Id, logger);
98114

99115
if (DetectAndReportInsecureSources(args.AllowInsecureConnections, sourceRepositories.Select(r => r.PackageSource), logger))
100116
{

src/NuGet.Core/NuGet.CommandLine.XPlat/Strings.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/NuGet.Core/NuGet.CommandLine.XPlat/Strings.resx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,4 +1162,9 @@ Do not translate "PackageVersion"</comment>
11621162
<comment>0 - package source name
11631163
1 - package name</comment>
11641164
</data>
1165+
<data name="PackageDownloadCommand_PackageSourceMapping_NoSourcesMapped" xml:space="preserve">
1166+
<value>Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</value>
1167+
<comment>{0} = package ID
1168+
{1} = comma-separated list of all configured sources </comment>
1169+
</data>
11651170
</root>

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.cs.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,12 @@ Další informace najdete tady: https://docs.nuget.org/docs/reference/command-li
929929
<target state="translated">Identifikátor balíčku (např. Newtonsoft.Json)</target>
930930
<note />
931931
</trans-unit>
932+
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSourcesMapped">
933+
<source>Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</source>
934+
<target state="new">Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</target>
935+
<note>{0} = package ID
936+
{1} = comma-separated list of all configured sources </note>
937+
</trans-unit>
932938
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSuchSource">
933939
<source>The mapped source '{0}' for package '{1}' was not found among the configured sources.</source>
934940
<target state="translated">Mapovaný zdroj {0} pro balíček {1} nebyl nalezen mezi nakonfigurovanými zdroji.</target>

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.de.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,12 @@ Weitere Informationen finden Sie unter: https://docs.nuget.org/docs/reference/co
929929
<target state="translated">Paketbezeichner (z. B. „Newtonsoft.Json“).</target>
930930
<note />
931931
</trans-unit>
932+
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSourcesMapped">
933+
<source>Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</source>
934+
<target state="new">Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</target>
935+
<note>{0} = package ID
936+
{1} = comma-separated list of all configured sources </note>
937+
</trans-unit>
932938
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSuchSource">
933939
<source>The mapped source '{0}' for package '{1}' was not found among the configured sources.</source>
934940
<target state="translated">Die zugeordnete Quelle {0} für das Paket {1} wurde unter den konfigurierten Quellen nicht gefunden.</target>

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.es.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,12 @@ Para obtener más información, visite https://docs.nuget.org/docs/reference/com
929929
<target state="translated">Identificador del paquete (por ejemplo, 'Newtonsoft.Json').</target>
930930
<note />
931931
</trans-unit>
932+
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSourcesMapped">
933+
<source>Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</source>
934+
<target state="new">Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</target>
935+
<note>{0} = package ID
936+
{1} = comma-separated list of all configured sources </note>
937+
</trans-unit>
932938
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSuchSource">
933939
<source>The mapped source '{0}' for package '{1}' was not found among the configured sources.</source>
934940
<target state="translated">No se encontró el origen asignado '{0}' para el paquete '{1}' entre los orígenes configurados.</target>

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.fr.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,12 @@ Pour plus d'informations, visitez https://docs.nuget.org/docs/reference/command-
929929
<target state="translated">Identificateur de package (par exemple, « Newtonsoft.Json »).</target>
930930
<note />
931931
</trans-unit>
932+
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSourcesMapped">
933+
<source>Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</source>
934+
<target state="new">Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</target>
935+
<note>{0} = package ID
936+
{1} = comma-separated list of all configured sources </note>
937+
</trans-unit>
932938
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSuchSource">
933939
<source>The mapped source '{0}' for package '{1}' was not found among the configured sources.</source>
934940
<target state="translated">La source mappée « {0} » pour le package « {1} » est introuvable parmi les sources configurées.</target>

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.it.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,12 @@ Per altre informazioni, vedere https://docs.nuget.org/docs/reference/command-lin
929929
<target state="translated">Identificatore del pacchetto ,ad esempio 'Newtonsoft.Json'.</target>
930930
<note />
931931
</trans-unit>
932+
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSourcesMapped">
933+
<source>Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</source>
934+
<target state="new">Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</target>
935+
<note>{0} = package ID
936+
{1} = comma-separated list of all configured sources </note>
937+
</trans-unit>
932938
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSuchSource">
933939
<source>The mapped source '{0}' for package '{1}' was not found among the configured sources.</source>
934940
<target state="translated">L'origine mappata '{0}' per il pacchetto '{1}' non è stata trovata tra le origini configurate.</target>

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.ja.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,12 @@ For more information, visit https://docs.nuget.org/docs/reference/command-line-r
929929
<target state="translated">パッケージ識別子 (例: 'Newtonsoft.Json')。</target>
930930
<note />
931931
</trans-unit>
932+
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSourcesMapped">
933+
<source>Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</source>
934+
<target state="new">Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</target>
935+
<note>{0} = package ID
936+
{1} = comma-separated list of all configured sources </note>
937+
</trans-unit>
932938
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSuchSource">
933939
<source>The mapped source '{0}' for package '{1}' was not found among the configured sources.</source>
934940
<target state="translated">パッケージ '{1}' のマップされたソース '{0}' が、構成済みのソースの中に見つかりませんでした。</target>

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.ko.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,12 @@ For more information, visit https://docs.nuget.org/docs/reference/command-line-r
929929
<target state="translated">패키지 식별자(예: 'Newtonsoft.Json').</target>
930930
<note />
931931
</trans-unit>
932+
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSourcesMapped">
933+
<source>Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</source>
934+
<target state="new">Unable to download package '{0}'. PackageSourceMapping is enabled, but no mapped sources were found for this package. The following source(s) were not considered: {1}.</target>
935+
<note>{0} = package ID
936+
{1} = comma-separated list of all configured sources </note>
937+
</trans-unit>
932938
<trans-unit id="PackageDownloadCommand_PackageSourceMapping_NoSuchSource">
933939
<source>The mapped source '{0}' for package '{1}' was not found among the configured sources.</source>
934940
<target state="translated">구성된 원본 중 '{1}' 패키지에 대해 매핑된 원본 '{0}'을(를) 찾을 수 없습니다.</target>

0 commit comments

Comments
 (0)