From 66e43fef51e8f8765c8b7b29ecbaf6f3bccd2540 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 17 Jun 2026 11:24:18 -0700 Subject: [PATCH 01/13] Add NU5052 pack warning for non-restricted package IDs Emit NU5052 warning during pack when a package ID does not adhere to the restricted character set (ASCII letters, digits, dots, dashes, underscores with no consecutive dots or dashes). The warning is gated by SdkAnalysisLevel >= 11.0.100 using SdkAnalysisLevelMinimums.IsEnabled(). - Add PackageIdValidator.IsRestrictedPackageId() with restricted regex - Emit NU5052 in PackCommandRunner.BuildPackage() before builder.Save() - Plumb SdkAnalysisLevel/UsingMicrosoftNETSdk from MSBuild targets through PackTask/PackTaskLogic to PackArgs - Add unit tests for IsRestrictedPackageId and integration tests for NU5052 emission with SdkAnalysisLevel gating Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../IPackTaskRequest.cs | 2 + .../NuGet.Build.Tasks.Pack/PackTask.cs | 4 + .../NuGet.Build.Tasks.Pack/PackTaskLogic.cs | 2 + .../NuGet.Build.Tasks.Pack/PackTaskRequest.cs | 2 + .../NuGet.Build.Tasks.Pack.targets | 2 + .../NuGet.Commands/CommandArgs/PackArgs.cs | 3 + .../CommandRunners/PackCommandRunner.cs | 12 ++ .../PublicAPI/net472/PublicAPI.Unshipped.txt | 4 + .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 4 + .../NuGet.Commands/Strings.Designer.cs | 11 +- src/NuGet.Core/NuGet.Commands/Strings.resx | 3 + .../Utility/SdkAnalysisLevelMinimums.cs | 1 + .../NuGet.Commands/xlf/Strings.cs.xlf | 7 +- .../NuGet.Commands/xlf/Strings.de.xlf | 7 +- .../NuGet.Commands/xlf/Strings.es.xlf | 7 +- .../NuGet.Commands/xlf/Strings.fr.xlf | 7 +- .../NuGet.Commands/xlf/Strings.it.xlf | 7 +- .../NuGet.Commands/xlf/Strings.ja.xlf | 7 +- .../NuGet.Commands/xlf/Strings.ko.xlf | 7 +- .../NuGet.Commands/xlf/Strings.pl.xlf | 7 +- .../NuGet.Commands/xlf/Strings.pt-BR.xlf | 7 +- .../NuGet.Commands/xlf/Strings.ru.xlf | 7 +- .../NuGet.Commands/xlf/Strings.tr.xlf | 7 +- .../NuGet.Commands/xlf/Strings.zh-Hans.xlf | 7 +- .../NuGet.Commands/xlf/Strings.zh-Hant.xlf | 7 +- .../NuGet.Common/Errors/NuGetLogCode.cs | 5 + .../NuGet.Common/PublicAPI.Unshipped.txt | 1 + .../Resources/NuGetResources.Designer.cs | 9 + .../Resources/NuGetResources.resx | 3 + .../Resources/xlf/NuGetResources.cs.xlf | 7 +- .../Resources/xlf/NuGetResources.de.xlf | 7 +- .../Resources/xlf/NuGetResources.es.xlf | 7 +- .../Resources/xlf/NuGetResources.fr.xlf | 7 +- .../Resources/xlf/NuGetResources.it.xlf | 7 +- .../Resources/xlf/NuGetResources.ja.xlf | 7 +- .../Resources/xlf/NuGetResources.ko.xlf | 7 +- .../Resources/xlf/NuGetResources.pl.xlf | 7 +- .../Resources/xlf/NuGetResources.pt-BR.xlf | 7 +- .../Resources/xlf/NuGetResources.ru.xlf | 7 +- .../Resources/xlf/NuGetResources.tr.xlf | 7 +- .../Resources/xlf/NuGetResources.zh-Hans.xlf | 7 +- .../Resources/xlf/NuGetResources.zh-Hant.xlf | 7 +- .../Utility/PackageIdValidator.cs | 20 +++ .../PublicAPI/net472/PublicAPI.Unshipped.txt | 1 + .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 1 + .../PackCommandRunnerTests.cs | 166 ++++++++++++++++++ .../PackageIdValidatorTest.cs | 93 ++++++++++ 47 files changed, 504 insertions(+), 27 deletions(-) diff --git a/src/NuGet.Core/NuGet.Build.Tasks.Pack/IPackTaskRequest.cs b/src/NuGet.Core/NuGet.Build.Tasks.Pack/IPackTaskRequest.cs index 0e79f0a40d6..c162b28084b 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks.Pack/IPackTaskRequest.cs +++ b/src/NuGet.Core/NuGet.Build.Tasks.Pack/IPackTaskRequest.cs @@ -78,5 +78,7 @@ public interface IPackTaskRequest bool Deterministic { get; } string DeterministicTimestamp { get; } string PackageIcon { get; } + string SdkAnalysisLevel { get; } + string UsingMicrosoftNETSdk { get; } } } diff --git a/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTask.cs b/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTask.cs index b18935acb2a..7a4197ff4ad 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTask.cs +++ b/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTask.cs @@ -94,6 +94,8 @@ internal PackTask(IEnvironmentVariableReader environmentVariableReader) public bool Deterministic { get; set; } public string DeterministicTimestamp { get; set; } public string PackageIcon { get; set; } + public string SdkAnalysisLevel { get; set; } + public string UsingMicrosoftNETSdk { get; set; } public ILogger Logger => new MSBuildLogger(Log); private IPackTaskLogic _packTaskLogic; @@ -228,6 +230,8 @@ private IPackTaskRequest GetRequest() Deterministic = Deterministic, DeterministicTimestamp = MSBuildStringUtility.TrimAndGetNullForEmpty(DeterministicTimestamp), PackageIcon = MSBuildStringUtility.TrimAndGetNullForEmpty(PackageIcon), + SdkAnalysisLevel = MSBuildStringUtility.TrimAndGetNullForEmpty(SdkAnalysisLevel), + UsingMicrosoftNETSdk = MSBuildStringUtility.TrimAndGetNullForEmpty(UsingMicrosoftNETSdk), }; } } diff --git a/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs b/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs index df302f197cf..4695159bf05 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs +++ b/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs @@ -45,6 +45,8 @@ public PackArgs GetPackArgs(IPackTaskRequest request) Deterministic = request.Deterministic, DeterministicTimestamp = request.DeterministicTimestamp, WarningProperties = WarningProperties.GetWarningProperties(request.TreatWarningsAsErrors, request.WarningsAsErrors, request.NoWarn, request.WarningsNotAsErrors), + SdkAnalysisLevel = MSBuildRestoreUtility.GetSdkAnalysisLevel(request.SdkAnalysisLevel), + UsingMicrosoftNETSdk = MSBuildRestoreUtility.GetUsingMicrosoftNETSdk(request.UsingMicrosoftNETSdk), PackTargetArgs = new MSBuildPackTargetArgs() }; diff --git a/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskRequest.cs b/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskRequest.cs index a418b666ef6..cb868838e65 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskRequest.cs +++ b/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskRequest.cs @@ -73,5 +73,7 @@ public class PackTaskRequest : IPackTaskRequest public bool Deterministic { get; set; } public string DeterministicTimestamp { get; set; } public string PackageIcon { get; set; } + public string SdkAnalysisLevel { get; set; } + public string UsingMicrosoftNETSdk { get; set; } } } diff --git a/src/NuGet.Core/NuGet.Build.Tasks/NuGet.Build.Tasks.Pack.targets b/src/NuGet.Core/NuGet.Build.Tasks/NuGet.Build.Tasks.Pack.targets index 18c8ae815fe..286bba8f09a 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks/NuGet.Build.Tasks.Pack.targets +++ b/src/NuGet.Core/NuGet.Build.Tasks/NuGet.Build.Tasks.Pack.targets @@ -285,6 +285,8 @@ Copyright (c) .NET Foundation. All rights reserved. Deterministic="$(Deterministic)" DeterministicTimestamp="$(DeterministicTimestamp)" PackageIcon="$(PackageIcon)" + SdkAnalysisLevel="$(SdkAnalysisLevel)" + UsingMicrosoftNETSdk="$(UsingMicrosoftNETSdk)" /> diff --git a/src/NuGet.Core/NuGet.Commands/CommandArgs/PackArgs.cs b/src/NuGet.Core/NuGet.Commands/CommandArgs/PackArgs.cs index 08121dcdfc8..b68f5246845 100644 --- a/src/NuGet.Core/NuGet.Commands/CommandArgs/PackArgs.cs +++ b/src/NuGet.Core/NuGet.Commands/CommandArgs/PackArgs.cs @@ -11,6 +11,7 @@ using NuGet.Configuration; using NuGet.Packaging; using NuGet.ProjectModel; +using NuGet.Versioning; namespace NuGet.Commands { @@ -47,6 +48,8 @@ public class PackArgs public bool Deterministic { get; set; } public string DeterministicTimestamp { get; set; } public WarningProperties WarningProperties { get; set; } + public NuGetVersion SdkAnalysisLevel { get; set; } + public bool UsingMicrosoftNETSdk { get; set; } public MSBuildPackTargetArgs PackTargetArgs { get; set; } public Dictionary Properties { diff --git a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs index 06fe2ab03d3..95c3c17f5aa 100644 --- a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs +++ b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs @@ -116,6 +116,18 @@ private bool BuildPackage(PackageBuilder builder, string outputPath = null, bool outputPath = outputPath ?? GetOutputPath(builder, _packArgs, false, builder.Version); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); + // Warn if the package ID doesn't adhere to the restricted character set (NU5052) + if (!symbolsPackage && !PackageIdValidator.IsRestrictedPackageId(builder.Id)) + { + if (SdkAnalysisLevelMinimums.IsEnabled(_packArgs.SdkAnalysisLevel, _packArgs.UsingMicrosoftNETSdk, SdkAnalysisLevelMinimums.V11_0_100)) + { + _packArgs.Logger.Log( + PackagingLogMessage.CreateWarning( + string.Format(CultureInfo.CurrentCulture, Strings.RestrictedPackageIdWarning, builder.Id), + NuGetLogCode.NU5052)); + } + } + // Track if the package file was already present on disk bool isExistingPackage = File.Exists(outputPath); try diff --git a/src/NuGet.Core/NuGet.Commands/PublicAPI/net472/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Commands/PublicAPI/net472/PublicAPI.Unshipped.txt index 786336e2d51..5104c49f60b 100644 --- a/src/NuGet.Core/NuGet.Commands/PublicAPI/net472/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Commands/PublicAPI/net472/PublicAPI.Unshipped.txt @@ -1,6 +1,10 @@ #nullable enable ~NuGet.Commands.PackArgs.DeterministicTimestamp.get -> string ~NuGet.Commands.PackArgs.DeterministicTimestamp.set -> void +~NuGet.Commands.PackArgs.SdkAnalysisLevel.get -> NuGet.Versioning.NuGetVersion +~NuGet.Commands.PackArgs.SdkAnalysisLevel.set -> void +NuGet.Commands.PackArgs.UsingMicrosoftNETSdk.get -> bool +NuGet.Commands.PackArgs.UsingMicrosoftNETSdk.set -> void const NuGet.Commands.Restore.Utility.PackageSpecFactory.EnvironmentVariableName = "NUGET_USE_NEW_PACKAGESPEC_FACTORY" -> string! NuGet.Commands.Restore.IProject.GetGlobalProperty(string! propertyName) -> string? ~static NuGet.Commands.MSBuildRestoreUtility.GetDependencySpec(System.Collections.Generic.IEnumerable items, bool readOnly, bool collectAdditionalMessages) -> (NuGet.ProjectModel.DependencyGraphSpec, System.Collections.Generic.IReadOnlyList) diff --git a/src/NuGet.Core/NuGet.Commands/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Commands/PublicAPI/net8.0/PublicAPI.Unshipped.txt index 786336e2d51..5104c49f60b 100644 --- a/src/NuGet.Core/NuGet.Commands/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Commands/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -1,6 +1,10 @@ #nullable enable ~NuGet.Commands.PackArgs.DeterministicTimestamp.get -> string ~NuGet.Commands.PackArgs.DeterministicTimestamp.set -> void +~NuGet.Commands.PackArgs.SdkAnalysisLevel.get -> NuGet.Versioning.NuGetVersion +~NuGet.Commands.PackArgs.SdkAnalysisLevel.set -> void +NuGet.Commands.PackArgs.UsingMicrosoftNETSdk.get -> bool +NuGet.Commands.PackArgs.UsingMicrosoftNETSdk.set -> void const NuGet.Commands.Restore.Utility.PackageSpecFactory.EnvironmentVariableName = "NUGET_USE_NEW_PACKAGESPEC_FACTORY" -> string! NuGet.Commands.Restore.IProject.GetGlobalProperty(string! propertyName) -> string? ~static NuGet.Commands.MSBuildRestoreUtility.GetDependencySpec(System.Collections.Generic.IEnumerable items, bool readOnly, bool collectAdditionalMessages) -> (NuGet.ProjectModel.DependencyGraphSpec, System.Collections.Generic.IReadOnlyList) diff --git a/src/NuGet.Core/NuGet.Commands/Strings.Designer.cs b/src/NuGet.Core/NuGet.Commands/Strings.Designer.cs index 03bfa2d9916..c7325d52114 100644 --- a/src/NuGet.Core/NuGet.Commands/Strings.Designer.cs +++ b/src/NuGet.Core/NuGet.Commands/Strings.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 @@ -1241,6 +1241,15 @@ internal static string Log_AliasContainsDisallowedCharacters { } } + /// + /// Looks up a localized string similar to The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set.. + /// + internal static string RestrictedPackageIdWarning { + get { + return ResourceManager.GetString("RestrictedPackageIdWarning", resourceCulture); + } + } + /// /// Looks up a localized string similar to All projects are up-to-date for restore.. /// diff --git a/src/NuGet.Core/NuGet.Commands/Strings.resx b/src/NuGet.Core/NuGet.Commands/Strings.resx index a46be8b5252..19861e4fa20 100644 --- a/src/NuGet.Core/NuGet.Commands/Strings.resx +++ b/src/NuGet.Core/NuGet.Commands/Strings.resx @@ -1190,4 +1190,7 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f The project {0} contains a TargetFramework '{1}' with disallowed characters. TargetFramework names must contain only ASCII characters and must not contain path separators. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + diff --git a/src/NuGet.Core/NuGet.Commands/Utility/SdkAnalysisLevelMinimums.cs b/src/NuGet.Core/NuGet.Commands/Utility/SdkAnalysisLevelMinimums.cs index 1830f5f9c24..915725b9ace 100644 --- a/src/NuGet.Core/NuGet.Commands/Utility/SdkAnalysisLevelMinimums.cs +++ b/src/NuGet.Core/NuGet.Commands/Utility/SdkAnalysisLevelMinimums.cs @@ -39,6 +39,7 @@ internal static class SdkAnalysisLevelMinimums /// /// warning when packages use the deprecated MonoAndroid framework /// error when TargetFramework alias contains non-ASCII characters + /// warning when package ID does not adhere to the restricted character set (NU5052) /// /// internal static readonly NuGetVersion V11_0_100 = new("11.0.100"); diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf index dcba000dc5b..a3a172b9a88 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Upgradujte svou sadu .NET SDK nebo odeberte RestoreUseLegacyDependencyResolver, Vyřazuje se balíček {0} jako závislost {1}. Maximální verze, která se dá vyřadit, je {2}. 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference Soubor certifikátu {0} se nenašel. Seznam přijatelných způsobů, jak poskytnout certifikát, najdete tady: https://docs.nuget.org/docs/reference/command-line-reference diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf index 001771b30eb..d6659cfb046 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Aktualisieren Sie Ihr .NET SDK oder entfernen Sie RestoreUseLegacyDependencyReso Das Paket „{0}“ wird als Abhängigkeit von „{1}“ gekürzt. Die maximal kürzbare Version ist „{2}“. 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference Die Zertifikatdatei "{0}" wurde nicht gefunden. Eine Liste der anerkannten Methoden zur Bereitstellung eines Zertifikats finden Sie unter https://docs.nuget.org/docs/reference/command-line-reference. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf index 599f169e127..efd1d622c8a 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Actualice el SDK de .NET o quite RestoreUseLegacyDependencyResolver para usar es Eliminando el paquete '{0}' como una dependencia de '{1}'. La versión máxima que se puede eliminar es '{2}' 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference No se encontró el archivo de certificado "{0}". Para obtener una lista de las formas aceptadas de proporcionar un certificado, visite https://docs.nuget.org/docs/reference/command-line-reference diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf index ba8bcd2a635..dcaee7e4de7 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Mettez à niveau votre Kit de développement logiciel (SDK) .NET ou supprimez Re Nettoyage du package « {0} » en tant que dépendance de « {1} ». La version maximale pouvant être nettoyée est « {2} » 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference Le fichier de certificat '{0}' est introuvable. Pour obtenir la liste des méthodes acceptées d'émission de certificats, accédez à https://docs.nuget.org/docs/reference/command-line-reference diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf index 1d7251d6fe0..183f400e1b4 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Per usare questa funzionalità, aggiornare .NET SDK o rimuovere RestoreUseLegacy Rimozione del pacchetto '{0}' come dipendenza di '{1}'. La versione massima rimovibile è '{2}' 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference Il file di certificato '{0}' non è stato trovato. Per un elenco dei modi accettati per specificare un certificato, vedere https://docs.nuget.org/docs/reference/command-line-reference diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf index 88192b0cf42..29d71edc57c 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f パッケージ '{0}' を '{1}' の依存関係として取り除いています。取り除きが可能な最大バージョンは '{2}' です 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference 証明書ファイル '{0}' は見つかりませんでした。証明書を提供する承認済みの方法のリストについて、https://docs.nuget.org/docs/reference/command-line-reference をご覧ください diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ko.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ko.xlf index d9804d0ebb3..b3d2775777a 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ko.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ko.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f 패키지 '{0}'을(를) '{1}'의 종속성으로 잘라내는 중입니다. 잘라내기 가능한 최대 버전은 '{2}'입니다. 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference 인증서 파일 '{0}'을(를) 찾을 수 없습니다. 인증서를 제공하는 허용된 방법 목록은 https://docs.nuget.org/docs/reference/command-line-reference를 참조하세요. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.pl.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.pl.xlf index 14c268f5ebd..a97fb82c60b 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.pl.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.pl.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Uaktualnij zestaw .NET SDK lub usuń RestoreUseLegacyDependencyResolver, aby kor Oczyszczanie pakietu „{0}” jako zależności „{1}”. Maksymalna wersja możliwa do oczyszczenia to „{2}” 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference Nie odnaleziono pliku certyfikatu „{0}”. Aby uzyskać listę akceptowanych sposobów dostarczenia certyfikatu, odwiedź stronę https://docs.nuget.org/docs/reference/command-line-reference diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.pt-BR.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.pt-BR.xlf index 560055ef5c4..f06428e00f4 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.pt-BR.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.pt-BR.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Atualize o SDK do .NET ou remova RestoreUseLegacyDependencyResolver para usar es Podando o pacote '{0}' como dependência de '{1}'. A versão máxima que pode ser removida é '{2}' 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference O arquivo de certificado '{0}' não foi encontrado. Para obter uma lista das maneiras aceitas de fornecimento de certificado, visite https://docs.nuget.org/docs/reference/command-line-reference diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ru.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ru.xlf index fba35e46239..7181829bffb 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ru.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ru.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f Урезание пакета "{0}" как зависимости "{1}". Максимальная версия, которую можно урезать: "{2}" 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference Файл сертификата "{0}" не найден. Допустимые способы предоставления сертификатов см. на странице https://docs.nuget.org/docs/reference/command-line-reference. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.tr.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.tr.xlf index 35d5461da00..ed9d13e9222 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.tr.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.tr.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Bu özelliği kullanmak için .NET SDK'nizi yükseltin veya RestoreUseLegacyDepe ‘{0}’ paketini ‘{1}’ bağımlılığı olarak ayıklama. Maksimum ayıklanabilir sürüm ‘{2}’ 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference '{0}' sertifika dosyası bulunamadı. Kabul edilen sertifika sağlama yollarının listesi için bkz. https://docs.nuget.org/docs/reference/command-line-reference diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hans.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hans.xlf index 94971dc34d1..8263c656c8a 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hans.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hans.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f 正在将包 "{0}" 作为 "{1}" 的依赖项进行删除。最大可删除版本为 "{2}" 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference 找不到文件“{0}”。要获取接受的证书提供方式列表,请访问 https://docs.nuget.org/docs/reference/command-line-reference diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hant.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hant.xlf index 913efa38769..17e53c1e45d 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hant.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hant.xlf @@ -1,4 +1,4 @@ - + @@ -1113,6 +1113,11 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f 修剪套件「{0}」作為「{1}」的相依性。最大可修剪版本為「{2}」 0 - package id and version, 1 - version + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Certificate file '{0}' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference 找不到憑證檔案 '{0}'。如需可接受的憑證提供方法清單,請前往 https://docs.microsoft.com/zh-tw/nuget/reference/nuget-exe-cli-reference diff --git a/src/NuGet.Core/NuGet.Common/Errors/NuGetLogCode.cs b/src/NuGet.Core/NuGet.Common/Errors/NuGetLogCode.cs index c65186b59d3..ad54e97c634 100644 --- a/src/NuGet.Core/NuGet.Common/Errors/NuGetLogCode.cs +++ b/src/NuGet.Core/NuGet.Common/Errors/NuGetLogCode.cs @@ -908,6 +908,11 @@ public enum NuGetLogCode /// NU5051 = 5051, + /// + /// Package ID does not adhere to the restricted set of characters + /// + NU5052 = 5052, + /// /// AssemblyOutsideLibWarning /// diff --git a/src/NuGet.Core/NuGet.Common/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Common/PublicAPI.Unshipped.txt index 479ec93463f..e77c59ee2ea 100644 --- a/src/NuGet.Core/NuGet.Common/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Common/PublicAPI.Unshipped.txt @@ -1,3 +1,4 @@ #nullable enable NuGet.Common.NuGetLogCode.NU1512 = 1512 -> NuGet.Common.NuGetLogCode +NuGet.Common.NuGetLogCode.NU5052 = 5052 -> NuGet.Common.NuGetLogCode NuGet.Common.NuGetLogCode.NU5502 = 5502 -> NuGet.Common.NuGetLogCode diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs index 6785129b920..a6da7c92b5e 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs @@ -177,6 +177,15 @@ internal static string InvalidPackageId { } } + /// + /// Looks up a localized string similar to The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set.. + /// + internal static string RestrictedPackageIdWarning { + get { + return ResourceManager.GetString("RestrictedPackageIdWarning", resourceCulture); + } + } + /// /// Looks up a localized string similar to <dependencies> element must not contain both <group> and <dependency> child elements.. /// diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx index 07fec34ec9c..2693522521f 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx @@ -139,6 +139,9 @@ The package ID '{0}' contains invalid characters. Examples of valid package IDs include 'MyPackage' and 'MyPackage.Sample'. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The schema version of '{0}' is incompatible with version {1} of NuGet. Upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf index 54c7a0e6de6..f674a6b5e2f 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ Soubor readme {0} v balíčku neexistuje. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. Neznámá verze schématu {0} diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf index 546ba09874e..0f80cf8fa0d 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ Die Infodatei "{0}" ist nicht im Paket vorhanden. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. Unbekannte Schemaversion "{0}". diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf index a7e3d819b77..0f352774eb3 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ No existe el archivo Léame "{0}" en el paquete. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. Versión de esquema desconocida '{0}'. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf index 5eba2cb4300..36a35a31b23 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ Le fichier readme '{0}' n'existe pas dans le package. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. Version de schéma '{0}' inconnue. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf index 2ab8c49957d..6c0f1e16e8c 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ Il file leggimi '{0}' non esiste nel pacchetto. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. Versione dello schema '{0}' sconosciuta. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf index 7e908721833..7389d8a6694 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ Readme ファイル '{0}' がパッケージに存在しません。 + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. 不明なスキーマのバージョン '{0}' です。 diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf index dcbd98aaaa4..f26a45a5e35 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ 추가 정보 파일 '{0}'이(가) 패키지에 없습니다. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. 알 수 없는 스키마 버전 '{0}'입니다. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf index 04fa894c35d..3cbf258a3df 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ Plik readme „{0}” nie istnieje w pakiecie. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. Nieznana wersja schematu „{0}”. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf index 0963afb6206..e7fc159392d 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ O arquivo Leiame '{0}' não existe no pacote. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. Versão de esquema '{0}' desconhecida. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf index b65e53748b8..837ba46c2e7 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ Файл сведений "{0}" отсутствует в пакете. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. Неизвестная схема версии "{0}". diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf index 3e28d6386b3..d3f86f19365 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ '{0}' benioku dosyası pakette yok. + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. Bilinmeyen şema sürümü '{0}'. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf index e6168f953f5..ea64811b3ad 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ 包中不存在自述文件“{0}”。 + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. 未知的架构版本“{0}”。 diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf index 52250973502..827afd625ac 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf @@ -1,4 +1,4 @@ - + @@ -197,6 +197,11 @@ 讀我檔案 '{0}' 不存在於這個套件中。 + + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + + Unknown schema version '{0}'. 未知的結構描述版本 '{0}'。 diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs index 486fc9b3772..ca657e33fcf 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs @@ -19,6 +19,10 @@ public static class PackageIdValidator options: RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant, matchTimeout: TimeSpan.FromSeconds(10)); + private static readonly Regex RestrictedIdRegex = new Regex(pattern: @"^[A-Za-z0-9_](?!.*[.\-]{2})[A-Za-z0-9.\-]{0,99}$", + options: RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant, + matchTimeout: TimeSpan.FromSeconds(10)); + public static bool IsValidPackageId(string packageId) { if (packageId == null) @@ -28,6 +32,22 @@ public static bool IsValidPackageId(string packageId) return IdRegex.IsMatch(packageId); } + /// + /// Checks whether the package ID adheres to the restricted set of characters allowed in package IDs. + /// The restricted set requires: starting with a letter, digit, or underscore; containing only ASCII letters, + /// digits, dots, and dashes; no consecutive dots or dashes; and being 100 characters or less. + /// + /// The package ID to validate. + /// true if the package ID adheres to the restricted character set; otherwise, false. + public static bool IsRestrictedPackageId(string packageId) + { + if (packageId == null) + { + throw new ArgumentNullException(nameof(packageId)); + } + return RestrictedIdRegex.IsMatch(packageId); + } + public static void ValidatePackageId(string packageId) { if (packageId.Length > MaxPackageIdLength) diff --git a/src/NuGet.Core/NuGet.Packaging/PublicAPI/net472/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Packaging/PublicAPI/net472/PublicAPI.Unshipped.txt index f130df65afa..9feb03ea2e6 100644 --- a/src/NuGet.Core/NuGet.Packaging/PublicAPI/net472/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Packaging/PublicAPI/net472/PublicAPI.Unshipped.txt @@ -1,2 +1,3 @@ #nullable enable NuGet.Packaging.PackageBuilder.DeterministicTimestamp.init -> void +static NuGet.Packaging.PackageIdValidator.IsRestrictedPackageId(string! packageId) -> bool diff --git a/src/NuGet.Core/NuGet.Packaging/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Packaging/PublicAPI/net8.0/PublicAPI.Unshipped.txt index f130df65afa..9feb03ea2e6 100644 --- a/src/NuGet.Core/NuGet.Packaging/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Packaging/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -1,2 +1,3 @@ #nullable enable NuGet.Packaging.PackageBuilder.DeterministicTimestamp.init -> void +static NuGet.Packaging.PackageIdValidator.IsRestrictedPackageId(string! packageId) -> bool diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs index 1bb04d2d52b..6eb0a705847 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs @@ -9,6 +9,7 @@ using FluentAssertions; using NuGet.Common; using NuGet.Packaging; +using NuGet.ProjectModel; using NuGet.Test.Utility; using NuGet.Versioning; using Xunit; @@ -258,5 +259,170 @@ public void Dispose() _testDirectory.Dispose(); } } + + [Theory] + [InlineData("Contöso.Utilities")] + [InlineData("\u0421ontoso.Utilities")] // Cyrillic С + public void BuildPackage_NonRestrictedPackageId_WithSdkAnalysisLevelEnabled_EmitsNU5052(string packageId) + { + using (var testDirectory = TestDirectory.Create()) + { + // Arrange + var nuspecPath = Path.Combine(testDirectory.Path, $"{packageId}.nuspec"); + File.WriteAllText(nuspecPath, $@" + + + {packageId} + 1.0.0 + test + test + + + + +"); + + var logger = new TestLogger(); + var args = new PackArgs() + { + CurrentDirectory = testDirectory.Path, + Exclude = Enumerable.Empty(), + Logger = new PackCollectorLogger(logger, new WarningProperties()), + Path = nuspecPath, + SdkAnalysisLevel = new NuGetVersion("11.0.100"), + UsingMicrosoftNETSdk = true, + }; + var runner = new PackCommandRunner(args, createProjectFactory: null); + + // Act + runner.RunPackageBuild(); + + // Assert + logger.WarningMessages.Should().Contain(m => m.Contains("NU5052")); + } + } + + [Fact] + public void BuildPackage_NonRestrictedPackageId_WithSdkAnalysisLevelBelow11_DoesNotEmitNU5052() + { + using (var testDirectory = TestDirectory.Create()) + { + // Arrange + string packageId = "Contöso.Utilities"; + var nuspecPath = Path.Combine(testDirectory.Path, "test.nuspec"); + File.WriteAllText(nuspecPath, $@" + + + {packageId} + 1.0.0 + test + test + + + + +"); + + var logger = new TestLogger(); + var args = new PackArgs() + { + CurrentDirectory = testDirectory.Path, + Exclude = Enumerable.Empty(), + Logger = new PackCollectorLogger(logger, new WarningProperties()), + Path = nuspecPath, + SdkAnalysisLevel = new NuGetVersion("10.0.100"), + UsingMicrosoftNETSdk = true, + }; + var runner = new PackCommandRunner(args, createProjectFactory: null); + + // Act + runner.RunPackageBuild(); + + // Assert - SdkAnalysisLevel < 11.0.100, warning should not be emitted + logger.WarningMessages.Should().NotContain(m => m.Contains("NU5052")); + } + } + + [Fact] + public void BuildPackage_NonRestrictedPackageId_NonSdkProject_EmitsNU5052() + { + using (var testDirectory = TestDirectory.Create()) + { + // Arrange + string packageId = "Contöso.Utilities"; + var nuspecPath = Path.Combine(testDirectory.Path, "test.nuspec"); + File.WriteAllText(nuspecPath, $@" + + + {packageId} + 1.0.0 + test + test + + + + +"); + + var logger = new TestLogger(); + var args = new PackArgs() + { + CurrentDirectory = testDirectory.Path, + Exclude = Enumerable.Empty(), + Logger = new PackCollectorLogger(logger, new WarningProperties()), + Path = nuspecPath, + SdkAnalysisLevel = null, + UsingMicrosoftNETSdk = false, + }; + var runner = new PackCommandRunner(args, createProjectFactory: null); + + // Act + runner.RunPackageBuild(); + + // Assert - Non-SDK project, warning should be emitted (latest defaults) + logger.WarningMessages.Should().Contain(m => m.Contains("NU5052")); + } + } + + [Fact] + public void BuildPackage_NonRestrictedPackageId_SdkProjectNoAnalysisLevel_DoesNotEmitNU5052() + { + using (var testDirectory = TestDirectory.Create()) + { + // Arrange + string packageId = "Contöso.Utilities"; + var nuspecPath = Path.Combine(testDirectory.Path, "test.nuspec"); + File.WriteAllText(nuspecPath, $@" + + + {packageId} + 1.0.0 + test + test + + + + +"); + + var logger = new TestLogger(); + var args = new PackArgs() + { + CurrentDirectory = testDirectory.Path, + Exclude = Enumerable.Empty(), + Logger = new PackCollectorLogger(logger, new WarningProperties()), + Path = nuspecPath, + SdkAnalysisLevel = null, + UsingMicrosoftNETSdk = true, + }; + var runner = new PackCommandRunner(args, createProjectFactory: null); + + // Act + runner.RunPackageBuild(); + + // Assert - SDK project with no SdkAnalysisLevel assumes 8.0.400, warning should not be emitted + logger.WarningMessages.Should().NotContain(m => m.Contains("NU5052")); + } + } } } diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs index 8fa66e638f5..6b24b9bbd0d 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs @@ -201,5 +201,98 @@ public void IdExceedingMaxLengthThrows(int idTestLength) () => PackageIdValidator.ValidatePackageId(packageId), "Id must not exceed 100 characters."); } + + [Theory] + [InlineData("Contoso.Utilities")] + [InlineData("My.Package-1.0")] + [InlineData("A")] + [InlineData("_internal")] + [InlineData("1.2.3")] + [InlineData("NuGet.Core")] + [InlineData("Microsoft.Extensions.Logging")] + public void IsRestrictedPackageId_ValidIds_ReturnsTrue(string packageId) + { + // Act + bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + + // Assert + Assert.True(result, $"Expected '{packageId}' to be a valid restricted package ID."); + } + + [Theory] + [InlineData("Contöso.Utilities")] // non-ASCII ö + [InlineData("Contoso.Ütil")] // non-ASCII Ü + [InlineData("\u0421ontoso.Utilities")] // Cyrillic С homoglyph + [InlineData("Paquet.Français")] // non-ASCII ç + [InlineData("Paquete.Español")] // non-ASCII ñ + [InlineData("パッケージ")] // Japanese characters + public void IsRestrictedPackageId_NonAsciiIds_ReturnsFalse(string packageId) + { + // Act + bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + + // Assert + Assert.False(result, $"Expected '{packageId}' to be an invalid restricted package ID."); + } + + [Theory] + [InlineData("Package..Double")] // consecutive dots + [InlineData("Package--Double")] // consecutive dashes + [InlineData("Package.-Mixed")] // consecutive dot-dash + [InlineData("Package-.Mixed")] // consecutive dash-dot + public void IsRestrictedPackageId_ConsecutiveSeparators_ReturnsFalse(string packageId) + { + // Act + bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + + // Assert + Assert.False(result, $"Expected '{packageId}' to be an invalid restricted package ID (consecutive separators)."); + } + + [Theory] + [InlineData(".StartsWithDot")] + [InlineData("-StartsWithDash")] + public void IsRestrictedPackageId_InvalidStartCharacter_ReturnsFalse(string packageId) + { + // Act + bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + + // Assert + Assert.False(result, $"Expected '{packageId}' to be invalid (starts with separator)."); + } + + [Fact] + public void IsRestrictedPackageId_ExceedsMaxLength_ReturnsFalse() + { + // Arrange + string packageId = new string('A', 101); + + // Act + bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + + // Assert + Assert.False(result); + } + + [Fact] + public void IsRestrictedPackageId_ExactMaxLength_ReturnsTrue() + { + // Arrange + string packageId = "A" + new string('b', 99); + + // Act + bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + + // Assert + Assert.True(result); + } + + [Fact] + public void IsRestrictedPackageId_NullThrows() + { + // Act & Assert + Assert.Throws(paramName: "packageId", + testCode: () => PackageIdValidator.IsRestrictedPackageId(null)); + } } } From 8a719cebbcea9c67bea9705a1bf887691d8d51d3 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 17 Jun 2026 13:59:02 -0700 Subject: [PATCH 02/13] Replace IsRestrictedPackageId regex with char-loop overload Replace the separate IsRestrictedPackageId() method and its regex with an IsValidPackageId(string, bool useRestrictedCharacterSet) overload that reuses the existing IdRegex and adds a fast char-loop for the restricted character check. Benchmarks showed the regex approach was 4x slower than baseline while the char-loop adds only ~15% overhead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CommandRunners/PackCommandRunner.cs | 2 +- .../Utility/PackageIdValidator.cs | 64 +++++++++++++++---- .../PublicAPI/net472/PublicAPI.Unshipped.txt | 2 +- .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 2 +- .../PackageIdValidatorTest.cs | 28 ++++---- 5 files changed, 68 insertions(+), 30 deletions(-) diff --git a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs index 95c3c17f5aa..979a7fc31cc 100644 --- a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs +++ b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs @@ -117,7 +117,7 @@ private bool BuildPackage(PackageBuilder builder, string outputPath = null, bool Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); // Warn if the package ID doesn't adhere to the restricted character set (NU5052) - if (!symbolsPackage && !PackageIdValidator.IsRestrictedPackageId(builder.Id)) + if (!symbolsPackage && !PackageIdValidator.IsValidPackageId(builder.Id, useRestrictedCharacterSet: true)) { if (SdkAnalysisLevelMinimums.IsEnabled(_packArgs.SdkAnalysisLevel, _packArgs.UsingMicrosoftNETSdk, SdkAnalysisLevelMinimums.V11_0_100)) { diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs index ca657e33fcf..278789157e4 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs @@ -19,10 +19,6 @@ public static class PackageIdValidator options: RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant, matchTimeout: TimeSpan.FromSeconds(10)); - private static readonly Regex RestrictedIdRegex = new Regex(pattern: @"^[A-Za-z0-9_](?!.*[.\-]{2})[A-Za-z0-9.\-]{0,99}$", - options: RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant, - matchTimeout: TimeSpan.FromSeconds(10)); - public static bool IsValidPackageId(string packageId) { if (packageId == null) @@ -33,19 +29,23 @@ public static bool IsValidPackageId(string packageId) } /// - /// Checks whether the package ID adheres to the restricted set of characters allowed in package IDs. - /// The restricted set requires: starting with a letter, digit, or underscore; containing only ASCII letters, - /// digits, dots, and dashes; no consecutive dots or dashes; and being 100 characters or less. + /// Validates the package ID. When is true, + /// additionally checks that the ID contains only ASCII letters, digits, dots, dashes, and underscores, + /// with no consecutive dots or dashes, and is 100 characters or less. /// - /// The package ID to validate. - /// true if the package ID adheres to the restricted character set; otherwise, false. - public static bool IsRestrictedPackageId(string packageId) + public static bool IsValidPackageId(string packageId, bool useRestrictedCharacterSet) { - if (packageId == null) + if (!IsValidPackageId(packageId)) { - throw new ArgumentNullException(nameof(packageId)); + return false; } - return RestrictedIdRegex.IsMatch(packageId); + + if (useRestrictedCharacterSet) + { + return IsRestrictedId(packageId); + } + + return true; } public static void ValidatePackageId(string packageId) @@ -60,5 +60,43 @@ public static void ValidatePackageId(string packageId) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, NuGetResources.InvalidPackageId, packageId)); } } + + private static bool IsRestrictedId(string packageId) + { + if (packageId.Length == 0 || packageId.Length > MaxPackageIdLength) + { + return false; + } + + char first = packageId[0]; + if (!IsAsciiLetterOrDigit(first) && first != '_') + { + return false; + } + + char prev = first; + for (int i = 1; i < packageId.Length; i++) + { + char c = packageId[i]; + if (!IsAsciiLetterOrDigit(c) && c != '.' && c != '-' && c != '_') + { + return false; + } + + if ((c == '.' || c == '-') && (prev == '.' || prev == '-')) + { + return false; + } + + prev = c; + } + + return true; + } + + private static bool IsAsciiLetterOrDigit(char c) + { + return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'); + } } } diff --git a/src/NuGet.Core/NuGet.Packaging/PublicAPI/net472/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Packaging/PublicAPI/net472/PublicAPI.Unshipped.txt index 9feb03ea2e6..a57f2f04705 100644 --- a/src/NuGet.Core/NuGet.Packaging/PublicAPI/net472/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Packaging/PublicAPI/net472/PublicAPI.Unshipped.txt @@ -1,3 +1,3 @@ #nullable enable NuGet.Packaging.PackageBuilder.DeterministicTimestamp.init -> void -static NuGet.Packaging.PackageIdValidator.IsRestrictedPackageId(string! packageId) -> bool +static NuGet.Packaging.PackageIdValidator.IsValidPackageId(string! packageId, bool useRestrictedCharacterSet) -> bool diff --git a/src/NuGet.Core/NuGet.Packaging/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Packaging/PublicAPI/net8.0/PublicAPI.Unshipped.txt index 9feb03ea2e6..a57f2f04705 100644 --- a/src/NuGet.Core/NuGet.Packaging/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Packaging/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -1,3 +1,3 @@ #nullable enable NuGet.Packaging.PackageBuilder.DeterministicTimestamp.init -> void -static NuGet.Packaging.PackageIdValidator.IsRestrictedPackageId(string! packageId) -> bool +static NuGet.Packaging.PackageIdValidator.IsValidPackageId(string! packageId, bool useRestrictedCharacterSet) -> bool diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs index 6b24b9bbd0d..da1403d834a 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs @@ -210,10 +210,10 @@ public void IdExceedingMaxLengthThrows(int idTestLength) [InlineData("1.2.3")] [InlineData("NuGet.Core")] [InlineData("Microsoft.Extensions.Logging")] - public void IsRestrictedPackageId_ValidIds_ReturnsTrue(string packageId) + public void IsValidPackageId_Restricted_ValidIds_ReturnsTrue(string packageId) { // Act - bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + bool result = PackageIdValidator.IsValidPackageId(packageId, useRestrictedCharacterSet: true); // Assert Assert.True(result, $"Expected '{packageId}' to be a valid restricted package ID."); @@ -226,10 +226,10 @@ public void IsRestrictedPackageId_ValidIds_ReturnsTrue(string packageId) [InlineData("Paquet.Français")] // non-ASCII ç [InlineData("Paquete.Español")] // non-ASCII ñ [InlineData("パッケージ")] // Japanese characters - public void IsRestrictedPackageId_NonAsciiIds_ReturnsFalse(string packageId) + public void IsValidPackageId_Restricted_NonAsciiIds_ReturnsFalse(string packageId) { // Act - bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + bool result = PackageIdValidator.IsValidPackageId(packageId, useRestrictedCharacterSet: true); // Assert Assert.False(result, $"Expected '{packageId}' to be an invalid restricted package ID."); @@ -240,10 +240,10 @@ public void IsRestrictedPackageId_NonAsciiIds_ReturnsFalse(string packageId) [InlineData("Package--Double")] // consecutive dashes [InlineData("Package.-Mixed")] // consecutive dot-dash [InlineData("Package-.Mixed")] // consecutive dash-dot - public void IsRestrictedPackageId_ConsecutiveSeparators_ReturnsFalse(string packageId) + public void IsValidPackageId_Restricted_ConsecutiveSeparators_ReturnsFalse(string packageId) { // Act - bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + bool result = PackageIdValidator.IsValidPackageId(packageId, useRestrictedCharacterSet: true); // Assert Assert.False(result, $"Expected '{packageId}' to be an invalid restricted package ID (consecutive separators)."); @@ -252,47 +252,47 @@ public void IsRestrictedPackageId_ConsecutiveSeparators_ReturnsFalse(string pack [Theory] [InlineData(".StartsWithDot")] [InlineData("-StartsWithDash")] - public void IsRestrictedPackageId_InvalidStartCharacter_ReturnsFalse(string packageId) + public void IsValidPackageId_Restricted_InvalidStartCharacter_ReturnsFalse(string packageId) { // Act - bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + bool result = PackageIdValidator.IsValidPackageId(packageId, useRestrictedCharacterSet: true); // Assert Assert.False(result, $"Expected '{packageId}' to be invalid (starts with separator)."); } [Fact] - public void IsRestrictedPackageId_ExceedsMaxLength_ReturnsFalse() + public void IsValidPackageId_Restricted_ExceedsMaxLength_ReturnsFalse() { // Arrange string packageId = new string('A', 101); // Act - bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + bool result = PackageIdValidator.IsValidPackageId(packageId, useRestrictedCharacterSet: true); // Assert Assert.False(result); } [Fact] - public void IsRestrictedPackageId_ExactMaxLength_ReturnsTrue() + public void IsValidPackageId_Restricted_ExactMaxLength_ReturnsTrue() { // Arrange string packageId = "A" + new string('b', 99); // Act - bool result = PackageIdValidator.IsRestrictedPackageId(packageId); + bool result = PackageIdValidator.IsValidPackageId(packageId, useRestrictedCharacterSet: true); // Assert Assert.True(result); } [Fact] - public void IsRestrictedPackageId_NullThrows() + public void IsValidPackageId_Restricted_NullThrows() { // Act & Assert Assert.Throws(paramName: "packageId", - testCode: () => PackageIdValidator.IsRestrictedPackageId(null)); + testCode: () => PackageIdValidator.IsValidPackageId(null, useRestrictedCharacterSet: true)); } } } From e2e7eae8ba7421b0f7f32816eef0449c3a7c314a Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 17 Jun 2026 15:25:08 -0700 Subject: [PATCH 03/13] Rename tests and consolidate gating scenarios into Theory Rename NonRestrictedPackageId to PackageIdWithInvalidCharacters for clarity. Consolidate the four SdkAnalysisLevel gating tests into a single Theory with MemberData. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../PackCommandRunnerTests.cs | 108 ++++-------------- 1 file changed, 23 insertions(+), 85 deletions(-) diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs index 6eb0a705847..6e235ed7d19 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs @@ -263,7 +263,7 @@ public void Dispose() [Theory] [InlineData("Contöso.Utilities")] [InlineData("\u0421ontoso.Utilities")] // Cyrillic С - public void BuildPackage_NonRestrictedPackageId_WithSdkAnalysisLevelEnabled_EmitsNU5052(string packageId) + public void BuildPackage_PackageIdWithInvalidCharacters_WithSdkAnalysisLevelEnabled_EmitsNU5052(string packageId) { using (var testDirectory = TestDirectory.Create()) { @@ -302,8 +302,9 @@ public void BuildPackage_NonRestrictedPackageId_WithSdkAnalysisLevelEnabled_Emit } } - [Fact] - public void BuildPackage_NonRestrictedPackageId_WithSdkAnalysisLevelBelow11_DoesNotEmitNU5052() + [Theory] + [MemberData(nameof(NU5052_EmitsWarning_GatingData))] + public void BuildPackage_PackageIdWithInvalidCharacters_EmitsNU5052_BasedOnSdkAnalysisLevel(string? sdkAnalysisLevel, bool usingMicrosoftNETSdk, bool expectWarning) { using (var testDirectory = TestDirectory.Create()) { @@ -330,99 +331,36 @@ public void BuildPackage_NonRestrictedPackageId_WithSdkAnalysisLevelBelow11_Does Exclude = Enumerable.Empty(), Logger = new PackCollectorLogger(logger, new WarningProperties()), Path = nuspecPath, - SdkAnalysisLevel = new NuGetVersion("10.0.100"), - UsingMicrosoftNETSdk = true, + SdkAnalysisLevel = sdkAnalysisLevel != null ? new NuGetVersion(sdkAnalysisLevel) : null, + UsingMicrosoftNETSdk = usingMicrosoftNETSdk, }; var runner = new PackCommandRunner(args, createProjectFactory: null); // Act runner.RunPackageBuild(); - // Assert - SdkAnalysisLevel < 11.0.100, warning should not be emitted - logger.WarningMessages.Should().NotContain(m => m.Contains("NU5052")); - } - } - - [Fact] - public void BuildPackage_NonRestrictedPackageId_NonSdkProject_EmitsNU5052() - { - using (var testDirectory = TestDirectory.Create()) - { - // Arrange - string packageId = "Contöso.Utilities"; - var nuspecPath = Path.Combine(testDirectory.Path, "test.nuspec"); - File.WriteAllText(nuspecPath, $@" - - - {packageId} - 1.0.0 - test - test - - - - -"); - - var logger = new TestLogger(); - var args = new PackArgs() + // Assert + if (expectWarning) { - CurrentDirectory = testDirectory.Path, - Exclude = Enumerable.Empty(), - Logger = new PackCollectorLogger(logger, new WarningProperties()), - Path = nuspecPath, - SdkAnalysisLevel = null, - UsingMicrosoftNETSdk = false, - }; - var runner = new PackCommandRunner(args, createProjectFactory: null); - - // Act - runner.RunPackageBuild(); - - // Assert - Non-SDK project, warning should be emitted (latest defaults) - logger.WarningMessages.Should().Contain(m => m.Contains("NU5052")); + logger.WarningMessages.Should().Contain(m => m.Contains("NU5052")); + } + else + { + logger.WarningMessages.Should().NotContain(m => m.Contains("NU5052")); + } } } - [Fact] - public void BuildPackage_NonRestrictedPackageId_SdkProjectNoAnalysisLevel_DoesNotEmitNU5052() + public static IEnumerable NU5052_EmitsWarning_GatingData() { - using (var testDirectory = TestDirectory.Create()) - { - // Arrange - string packageId = "Contöso.Utilities"; - var nuspecPath = Path.Combine(testDirectory.Path, "test.nuspec"); - File.WriteAllText(nuspecPath, $@" - - - {packageId} - 1.0.0 - test - test - - - - -"); - - var logger = new TestLogger(); - var args = new PackArgs() - { - CurrentDirectory = testDirectory.Path, - Exclude = Enumerable.Empty(), - Logger = new PackCollectorLogger(logger, new WarningProperties()), - Path = nuspecPath, - SdkAnalysisLevel = null, - UsingMicrosoftNETSdk = true, - }; - var runner = new PackCommandRunner(args, createProjectFactory: null); - - // Act - runner.RunPackageBuild(); - - // Assert - SDK project with no SdkAnalysisLevel assumes 8.0.400, warning should not be emitted - logger.WarningMessages.Should().NotContain(m => m.Contains("NU5052")); - } + // SdkAnalysisLevel >= 11.0.100, SDK project → emits + yield return new object?[] { "11.0.100", true, true }; + // SdkAnalysisLevel < 11.0.100, SDK project → does not emit + yield return new object?[] { "10.0.100", true, false }; + // Non-SDK project (null level, UsingMicrosoftNETSdk=false) → emits (latest defaults) + yield return new object?[] { null, false, true }; + // SDK project with no SdkAnalysisLevel (assumes 8.0.400) → does not emit + yield return new object?[] { null, true, false }; } } } From 1b756b8ca51229747607eb34045aee111bfa8969 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 17 Jun 2026 15:34:21 -0700 Subject: [PATCH 04/13] Add NoWarn and TreatWarningsAsErrors tests for NU5052, use InlineData Replace MemberData with InlineData for the gating theory. Add tests verifying that NoWarn suppresses NU5052 and TreatWarningsAsErrors elevates it to an error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../PackCommandRunnerTests.cs | 99 +++++++++++++++++-- 1 file changed, 89 insertions(+), 10 deletions(-) diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs index 6e235ed7d19..77713ae273e 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs @@ -303,7 +303,9 @@ public void BuildPackage_PackageIdWithInvalidCharacters_WithSdkAnalysisLevelEnab } [Theory] - [MemberData(nameof(NU5052_EmitsWarning_GatingData))] + [InlineData("10.0.100", true, false)] // SdkAnalysisLevel below 11, SDK project → suppressed + [InlineData(null, false, true)] // Non-SDK project (nuget.exe) → emits (latest defaults) + [InlineData(null, true, false)] // SDK project, no SdkAnalysisLevel (assumes 8.0.400) → suppressed public void BuildPackage_PackageIdWithInvalidCharacters_EmitsNU5052_BasedOnSdkAnalysisLevel(string? sdkAnalysisLevel, bool usingMicrosoftNETSdk, bool expectWarning) { using (var testDirectory = TestDirectory.Create()) @@ -351,16 +353,93 @@ public void BuildPackage_PackageIdWithInvalidCharacters_EmitsNU5052_BasedOnSdkAn } } - public static IEnumerable NU5052_EmitsWarning_GatingData() + [Fact] + public void BuildPackage_PackageIdWithInvalidCharacters_NoWarnSuppressesNU5052() + { + using (var testDirectory = TestDirectory.Create()) + { + // Arrange + string packageId = "Contöso.Utilities"; + var nuspecPath = Path.Combine(testDirectory.Path, "test.nuspec"); + File.WriteAllText(nuspecPath, $@" + + + {packageId} + 1.0.0 + test + test + + + + +"); + + var warningProperties = new WarningProperties(); + warningProperties.NoWarn.Add(NuGetLogCode.NU5052); + + var logger = new TestLogger(); + var args = new PackArgs() + { + CurrentDirectory = testDirectory.Path, + Exclude = Enumerable.Empty(), + Logger = new PackCollectorLogger(logger, warningProperties), + Path = nuspecPath, + SdkAnalysisLevel = new NuGetVersion("11.0.100"), + UsingMicrosoftNETSdk = true, + }; + var runner = new PackCommandRunner(args, createProjectFactory: null); + + // Act + runner.RunPackageBuild(); + + // Assert + logger.WarningMessages.Should().NotContain(m => m.Contains("NU5052")); + } + } + + [Fact] + public void BuildPackage_PackageIdWithInvalidCharacters_TreatWarningsAsErrors_RaisesNU5052AsError() { - // SdkAnalysisLevel >= 11.0.100, SDK project → emits - yield return new object?[] { "11.0.100", true, true }; - // SdkAnalysisLevel < 11.0.100, SDK project → does not emit - yield return new object?[] { "10.0.100", true, false }; - // Non-SDK project (null level, UsingMicrosoftNETSdk=false) → emits (latest defaults) - yield return new object?[] { null, false, true }; - // SDK project with no SdkAnalysisLevel (assumes 8.0.400) → does not emit - yield return new object?[] { null, true, false }; + using (var testDirectory = TestDirectory.Create()) + { + // Arrange + string packageId = "Contöso.Utilities"; + var nuspecPath = Path.Combine(testDirectory.Path, "test.nuspec"); + File.WriteAllText(nuspecPath, $@" + + + {packageId} + 1.0.0 + test + test + + + + +"); + + var warningProperties = new WarningProperties(); + warningProperties.AllWarningsAsErrors = true; + + var logger = new TestLogger(); + var args = new PackArgs() + { + CurrentDirectory = testDirectory.Path, + Exclude = Enumerable.Empty(), + Logger = new PackCollectorLogger(logger, warningProperties), + Path = nuspecPath, + SdkAnalysisLevel = new NuGetVersion("11.0.100"), + UsingMicrosoftNETSdk = true, + }; + var runner = new PackCommandRunner(args, createProjectFactory: null); + + // Act + runner.RunPackageBuild(); + + // Assert - warning is upgraded to error + logger.ErrorMessages.Should().Contain(m => m.Contains("NU5052")); + logger.WarningMessages.Should().NotContain(m => m.Contains("NU5052")); + } } } } From 2211b5b1ab18412cf51c83085f7c466d10a789e1 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 17 Jun 2026 15:57:15 -0700 Subject: [PATCH 05/13] Merge NU5052 test theories, remove duplicate restricted tests Merge the two separate NU5052 theories into one with all dimensions (packageId, sdkAnalysisLevel, usingMicrosoftNETSdk, expectWarning). Remove restricted PackageIdValidator tests that duplicate existing IsValidPackageId tests (consecutive separators, invalid start char, null). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../PackCommandRunnerTests.cs | 53 +++---------------- .../PackageIdValidatorTest.cs | 34 ------------ 2 files changed, 6 insertions(+), 81 deletions(-) diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs index 77713ae273e..063cd78bd98 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs @@ -261,57 +261,16 @@ public void Dispose() } [Theory] - [InlineData("Contöso.Utilities")] - [InlineData("\u0421ontoso.Utilities")] // Cyrillic С - public void BuildPackage_PackageIdWithInvalidCharacters_WithSdkAnalysisLevelEnabled_EmitsNU5052(string packageId) + [InlineData("Contöso.Utilities", "11.0.100", true, true)] // non-ASCII ö, enabled → emits + [InlineData("\u0421ontoso.Utilities", "11.0.100", true, true)] // Cyrillic С, enabled → emits + [InlineData("Contöso.Utilities", "10.0.100", true, false)] // below threshold → suppressed + [InlineData("Contöso.Utilities", null, false, true)] // non-SDK project (nuget.exe) → emits + [InlineData("Contöso.Utilities", null, true, false)] // SDK project, no level (assumes 8.0.400) → suppressed + public void BuildPackage_PackageIdWithInvalidCharacters_EmitsNU5052_BasedOnSdkAnalysisLevel(string packageId, string? sdkAnalysisLevel, bool usingMicrosoftNETSdk, bool expectWarning) { using (var testDirectory = TestDirectory.Create()) { // Arrange - var nuspecPath = Path.Combine(testDirectory.Path, $"{packageId}.nuspec"); - File.WriteAllText(nuspecPath, $@" - - - {packageId} - 1.0.0 - test - test - - - - -"); - - var logger = new TestLogger(); - var args = new PackArgs() - { - CurrentDirectory = testDirectory.Path, - Exclude = Enumerable.Empty(), - Logger = new PackCollectorLogger(logger, new WarningProperties()), - Path = nuspecPath, - SdkAnalysisLevel = new NuGetVersion("11.0.100"), - UsingMicrosoftNETSdk = true, - }; - var runner = new PackCommandRunner(args, createProjectFactory: null); - - // Act - runner.RunPackageBuild(); - - // Assert - logger.WarningMessages.Should().Contain(m => m.Contains("NU5052")); - } - } - - [Theory] - [InlineData("10.0.100", true, false)] // SdkAnalysisLevel below 11, SDK project → suppressed - [InlineData(null, false, true)] // Non-SDK project (nuget.exe) → emits (latest defaults) - [InlineData(null, true, false)] // SDK project, no SdkAnalysisLevel (assumes 8.0.400) → suppressed - public void BuildPackage_PackageIdWithInvalidCharacters_EmitsNU5052_BasedOnSdkAnalysisLevel(string? sdkAnalysisLevel, bool usingMicrosoftNETSdk, bool expectWarning) - { - using (var testDirectory = TestDirectory.Create()) - { - // Arrange - string packageId = "Contöso.Utilities"; var nuspecPath = Path.Combine(testDirectory.Path, "test.nuspec"); File.WriteAllText(nuspecPath, $@" diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs index da1403d834a..b2066c935cf 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageIdValidatorTest.cs @@ -235,32 +235,6 @@ public void IsValidPackageId_Restricted_NonAsciiIds_ReturnsFalse(string packageI Assert.False(result, $"Expected '{packageId}' to be an invalid restricted package ID."); } - [Theory] - [InlineData("Package..Double")] // consecutive dots - [InlineData("Package--Double")] // consecutive dashes - [InlineData("Package.-Mixed")] // consecutive dot-dash - [InlineData("Package-.Mixed")] // consecutive dash-dot - public void IsValidPackageId_Restricted_ConsecutiveSeparators_ReturnsFalse(string packageId) - { - // Act - bool result = PackageIdValidator.IsValidPackageId(packageId, useRestrictedCharacterSet: true); - - // Assert - Assert.False(result, $"Expected '{packageId}' to be an invalid restricted package ID (consecutive separators)."); - } - - [Theory] - [InlineData(".StartsWithDot")] - [InlineData("-StartsWithDash")] - public void IsValidPackageId_Restricted_InvalidStartCharacter_ReturnsFalse(string packageId) - { - // Act - bool result = PackageIdValidator.IsValidPackageId(packageId, useRestrictedCharacterSet: true); - - // Assert - Assert.False(result, $"Expected '{packageId}' to be invalid (starts with separator)."); - } - [Fact] public void IsValidPackageId_Restricted_ExceedsMaxLength_ReturnsFalse() { @@ -286,13 +260,5 @@ public void IsValidPackageId_Restricted_ExactMaxLength_ReturnsTrue() // Assert Assert.True(result); } - - [Fact] - public void IsValidPackageId_Restricted_NullThrows() - { - // Act & Assert - Assert.Throws(paramName: "packageId", - testCode: () => PackageIdValidator.IsValidPackageId(null, useRestrictedCharacterSet: true)); - } } } From 2038fa2e1ef9fa4377f3954b2bcc08c74d0c2d16 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 17 Jun 2026 16:04:42 -0700 Subject: [PATCH 06/13] Add integration test for NU5052 with SDK_NEXT gating Verify that dotnet pack with a non-ASCII PackageId emits NU5052 on .NET 11 (SDK_NEXT) and does not on .NET 10. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../PackCommandTests.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs index bce994b52ad..80954dd7523 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs @@ -6663,5 +6663,32 @@ private void SetupAliasedFrameworkProject( ProjectFileUtils.WriteXmlToFile(xml, stream); } + + [PlatformFact(Platform.Windows)] + public void PackCommand_PackageIdWithNonAsciiCharacters_NU5052() + { + using var testDirectory = _dotnetFixture.CreateTestDirectory(); + var projectName = "ClassLibrary1"; + var workingDirectory = Path.Combine(testDirectory, projectName); + + _dotnetFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib", testOutputHelper: _testOutputHelper); + var projectFile = Path.Combine(workingDirectory, $"{projectName}.csproj"); + + using (var stream = new FileStream(projectFile, FileMode.Open, FileAccess.ReadWrite)) + { + var xml = XDocument.Load(stream); + ProjectFileUtils.AddProperty(xml, "PackageId", "Contöso.Utilities"); + ProjectFileUtils.WriteXmlToFile(xml, stream); + } + + _dotnetFixture.RestoreProjectExpectSuccess(workingDirectory, projectName, testOutputHelper: _testOutputHelper); + var result = _dotnetFixture.PackProjectExpectSuccess(workingDirectory, projectName, $"-o {workingDirectory}", testOutputHelper: _testOutputHelper); + +#if SDK_NEXT + result.AllOutput.Should().Contain("NU5052"); +#else + result.AllOutput.Should().NotContain("NU5052"); +#endif + } } } From 57a396e0a80e2e92845d32f7725c9c54a9564b89 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 17 Jun 2026 16:08:51 -0700 Subject: [PATCH 07/13] Scope NU5052 warning to SDK projects only Only emit the restricted package ID warning (NU5052) when UsingMicrosoftNETSdk is true. Non-SDK projects (nuget.exe pack) do not emit this warning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../NuGet.Commands/CommandRunners/PackCommandRunner.cs | 2 +- .../NuGet.Commands.Test/PackCommandRunnerTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs index 979a7fc31cc..194f3f88697 100644 --- a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs +++ b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs @@ -117,7 +117,7 @@ private bool BuildPackage(PackageBuilder builder, string outputPath = null, bool Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); // Warn if the package ID doesn't adhere to the restricted character set (NU5052) - if (!symbolsPackage && !PackageIdValidator.IsValidPackageId(builder.Id, useRestrictedCharacterSet: true)) + if (!symbolsPackage && _packArgs.UsingMicrosoftNETSdk && !PackageIdValidator.IsValidPackageId(builder.Id, useRestrictedCharacterSet: true)) { if (SdkAnalysisLevelMinimums.IsEnabled(_packArgs.SdkAnalysisLevel, _packArgs.UsingMicrosoftNETSdk, SdkAnalysisLevelMinimums.V11_0_100)) { diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs index 063cd78bd98..a91f639329f 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs @@ -264,7 +264,7 @@ public void Dispose() [InlineData("Contöso.Utilities", "11.0.100", true, true)] // non-ASCII ö, enabled → emits [InlineData("\u0421ontoso.Utilities", "11.0.100", true, true)] // Cyrillic С, enabled → emits [InlineData("Contöso.Utilities", "10.0.100", true, false)] // below threshold → suppressed - [InlineData("Contöso.Utilities", null, false, true)] // non-SDK project (nuget.exe) → emits + [InlineData("Contöso.Utilities", null, false, false)] // non-SDK project (nuget.exe) → not emitted (SDK-only warning) [InlineData("Contöso.Utilities", null, true, false)] // SDK project, no level (assumes 8.0.400) → suppressed public void BuildPackage_PackageIdWithInvalidCharacters_EmitsNU5052_BasedOnSdkAnalysisLevel(string packageId, string? sdkAnalysisLevel, bool usingMicrosoftNETSdk, bool expectWarning) { From 38fe0d66f537acd2f9d65ae52fee9e58b5d613a0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Jun 2026 19:15:53 +0000 Subject: [PATCH 08/13] Address PR feedback for NU5052 wording and validator helper --- src/NuGet.Core/NuGet.Commands/Strings.resx | 2 +- src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.ko.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.pl.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.pt-BR.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.ru.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.tr.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hans.xlf | 4 ++-- src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hant.xlf | 4 ++-- .../PackageCreation/Utility/PackageIdValidator.cs | 10 +++++----- 15 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/NuGet.Core/NuGet.Commands/Strings.resx b/src/NuGet.Core/NuGet.Commands/Strings.resx index 19861e4fa20..087eea15fde 100644 --- a/src/NuGet.Core/NuGet.Commands/Strings.resx +++ b/src/NuGet.Core/NuGet.Commands/Strings.resx @@ -1191,6 +1191,6 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f The project {0} contains a TargetFramework '{1}' with disallowed characters. TargetFramework names must contain only ASCII characters and must not contain path separators. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf index a3a172b9a88..00a21d58555 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.cs.xlf @@ -1114,8 +1114,8 @@ Upgradujte svou sadu .NET SDK nebo odeberte RestoreUseLegacyDependencyResolver, 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf index d6659cfb046..33bd44551de 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.de.xlf @@ -1114,8 +1114,8 @@ Aktualisieren Sie Ihr .NET SDK oder entfernen Sie RestoreUseLegacyDependencyReso 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf index efd1d622c8a..087d425583a 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.es.xlf @@ -1114,8 +1114,8 @@ Actualice el SDK de .NET o quite RestoreUseLegacyDependencyResolver para usar es 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf index dcaee7e4de7..f810425ea37 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.fr.xlf @@ -1114,8 +1114,8 @@ Mettez à niveau votre Kit de développement logiciel (SDK) .NET ou supprimez Re 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf index 183f400e1b4..759ddba09e5 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.it.xlf @@ -1114,8 +1114,8 @@ Per usare questa funzionalità, aggiornare .NET SDK o rimuovere RestoreUseLegacy 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf index 29d71edc57c..8c1d789e2d0 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ja.xlf @@ -1114,8 +1114,8 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ko.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ko.xlf index b3d2775777a..a662168288f 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ko.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ko.xlf @@ -1114,8 +1114,8 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.pl.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.pl.xlf index a97fb82c60b..db6be2a2124 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.pl.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.pl.xlf @@ -1114,8 +1114,8 @@ Uaktualnij zestaw .NET SDK lub usuń RestoreUseLegacyDependencyResolver, aby kor 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.pt-BR.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.pt-BR.xlf index f06428e00f4..ec4782a5cfb 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.pt-BR.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.pt-BR.xlf @@ -1114,8 +1114,8 @@ Atualize o SDK do .NET ou remova RestoreUseLegacyDependencyResolver para usar es 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ru.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ru.xlf index 7181829bffb..ac891760d3d 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.ru.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.ru.xlf @@ -1114,8 +1114,8 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.tr.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.tr.xlf index ed9d13e9222..36c6f023652 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.tr.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.tr.xlf @@ -1114,8 +1114,8 @@ Bu özelliği kullanmak için .NET SDK'nizi yükseltin veya RestoreUseLegacyDepe 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hans.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hans.xlf index 8263c656c8a..a540e8482b7 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hans.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hans.xlf @@ -1114,8 +1114,8 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hant.xlf b/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hant.xlf index 17e53c1e45d..8c35bd57622 100644 --- a/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hant.xlf +++ b/src/NuGet.Core/NuGet.Commands/xlf/Strings.zh-Hant.xlf @@ -1114,8 +1114,8 @@ Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this f 0 - package id and version, 1 - version - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. + The package ID '{0}' is invalid. Package IDs must start with a letter, digit, or underscore, and contain only ASCII letters, digits, dots (.), dashes (-), and underscores (_), with no consecutive dots or dashes. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs index 278789157e4..86aaece2d55 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Utility/PackageIdValidator.cs @@ -63,6 +63,11 @@ public static void ValidatePackageId(string packageId) private static bool IsRestrictedId(string packageId) { + static bool IsAsciiLetterOrDigit(char c) + { + return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'); + } + if (packageId.Length == 0 || packageId.Length > MaxPackageIdLength) { return false; @@ -93,10 +98,5 @@ private static bool IsRestrictedId(string packageId) return true; } - - private static bool IsAsciiLetterOrDigit(char c) - { - return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'); - } } } From a3b0c849f0173682d2f808d3ea5bd33f49794713 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Tue, 23 Jun 2026 14:06:14 -0700 Subject: [PATCH 09/13] cleanup --- .../CommandRunners/PackCommandRunner.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs index 194f3f88697..8159031dcd9 100644 --- a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs +++ b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs @@ -117,15 +117,14 @@ private bool BuildPackage(PackageBuilder builder, string outputPath = null, bool Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); // Warn if the package ID doesn't adhere to the restricted character set (NU5052) - if (!symbolsPackage && _packArgs.UsingMicrosoftNETSdk && !PackageIdValidator.IsValidPackageId(builder.Id, useRestrictedCharacterSet: true)) + if (!symbolsPackage && _packArgs.UsingMicrosoftNETSdk && + SdkAnalysisLevelMinimums.IsEnabled(_packArgs.SdkAnalysisLevel, _packArgs.UsingMicrosoftNETSdk, SdkAnalysisLevelMinimums.V11_0_100) && + !PackageIdValidator.IsValidPackageId(builder.Id, useRestrictedCharacterSet: true)) { - if (SdkAnalysisLevelMinimums.IsEnabled(_packArgs.SdkAnalysisLevel, _packArgs.UsingMicrosoftNETSdk, SdkAnalysisLevelMinimums.V11_0_100)) - { - _packArgs.Logger.Log( - PackagingLogMessage.CreateWarning( - string.Format(CultureInfo.CurrentCulture, Strings.RestrictedPackageIdWarning, builder.Id), - NuGetLogCode.NU5052)); - } + _packArgs.Logger.Log( + PackagingLogMessage.CreateWarning( + string.Format(CultureInfo.CurrentCulture, Strings.RestrictedPackageIdWarning, builder.Id), + NuGetLogCode.NU5052)); } // Track if the package file was already present on disk From 7c52b2d6a0984eeaa63e76783a56313e9a855588 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Tue, 23 Jun 2026 14:10:54 -0700 Subject: [PATCH 10/13] cleanup --- .../NuGet.Commands/CommandRunners/PackCommandRunner.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs index 8159031dcd9..4c20e260f3a 100644 --- a/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs +++ b/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs @@ -117,8 +117,9 @@ private bool BuildPackage(PackageBuilder builder, string outputPath = null, bool Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); // Warn if the package ID doesn't adhere to the restricted character set (NU5052) - if (!symbolsPackage && _packArgs.UsingMicrosoftNETSdk && - SdkAnalysisLevelMinimums.IsEnabled(_packArgs.SdkAnalysisLevel, _packArgs.UsingMicrosoftNETSdk, SdkAnalysisLevelMinimums.V11_0_100) && + if (!symbolsPackage && + _packArgs.UsingMicrosoftNETSdk && + SdkAnalysisLevelMinimums.IsEnabled(_packArgs.SdkAnalysisLevel, _packArgs.UsingMicrosoftNETSdk, SdkAnalysisLevelMinimums.V11_0_100) && !PackageIdValidator.IsValidPackageId(builder.Id, useRestrictedCharacterSet: true)) { _packArgs.Logger.Log( From abb127ad0683a161af8e1b59b022fabbd7748beb Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 24 Jun 2026 17:48:36 -0700 Subject: [PATCH 11/13] revert unused --- .../Resources/NuGetResources.Designer.cs | 59 +++++++------------ .../Resources/NuGetResources.resx | 59 +++++++++---------- .../Resources/xlf/NuGetResources.cs.xlf | 5 -- .../Resources/xlf/NuGetResources.de.xlf | 5 -- .../Resources/xlf/NuGetResources.es.xlf | 5 -- .../Resources/xlf/NuGetResources.fr.xlf | 5 -- .../Resources/xlf/NuGetResources.it.xlf | 5 -- .../Resources/xlf/NuGetResources.ja.xlf | 5 -- .../Resources/xlf/NuGetResources.ko.xlf | 5 -- .../Resources/xlf/NuGetResources.pl.xlf | 5 -- .../Resources/xlf/NuGetResources.pt-BR.xlf | 5 -- .../Resources/xlf/NuGetResources.ru.xlf | 5 -- .../Resources/xlf/NuGetResources.tr.xlf | 5 -- .../Resources/xlf/NuGetResources.zh-Hans.xlf | 5 -- .../Resources/xlf/NuGetResources.zh-Hant.xlf | 5 -- 15 files changed, 48 insertions(+), 135 deletions(-) diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs index a6da7c92b5e..a319570a210 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 @@ -19,7 +19,7 @@ namespace NuGet.Packaging.PackageCreation.Resources { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class NuGetResources { @@ -177,15 +177,6 @@ internal static string InvalidPackageId { } } - /// - /// Looks up a localized string similar to The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set.. - /// - internal static string RestrictedPackageIdWarning { - get { - return ResourceManager.GetString("RestrictedPackageIdWarning", resourceCulture); - } - } - /// /// Looks up a localized string similar to <dependencies> element must not contain both <group> and <dependency> child elements.. /// @@ -374,62 +365,52 @@ internal static string PackageAuthoring_FileNotFound { return ResourceManager.GetString("PackageAuthoring_FileNotFound", resourceCulture); } } - + /// /// Looks up a localized string similar to Cannot open the readme file '{0}': {1}.. /// - internal static string ReadmeCannotOpenFile - { - get - { + internal static string ReadmeCannotOpenFile { + get { return ResourceManager.GetString("ReadmeCannotOpenFile", resourceCulture); } } - + /// - /// Looks up a localized string similar to The readme file is empty.. + /// Looks up a localized string similar to The readme file '{0}' is empty.. /// - internal static string ReadmeErrorEmpty - { - get - { + internal static string ReadmeErrorEmpty { + get { return ResourceManager.GetString("ReadmeErrorEmpty", resourceCulture); } } - + /// - /// Looks up a localized string similar to The readme file '{0}' has an invalid extension.. + /// Looks up a localized string similar to The readme file '{0}' has an invalid extension. It must end in .md.. /// - internal static string ReadmeFileExtensionIsInvalid - { - get - { + internal static string ReadmeFileExtensionIsInvalid { + get { return ResourceManager.GetString("ReadmeFileExtensionIsInvalid", resourceCulture); } } - + /// /// Looks up a localized string similar to The element 'readme' cannot be empty.. /// - internal static string ReadmeMissingRequiredValue - { - get - { + internal static string ReadmeMissingRequiredValue { + get { return ResourceManager.GetString("ReadmeMissingRequiredValue", resourceCulture); } } - + /// /// Looks up a localized string similar to The readme file '{0}' does not exist in the package.. /// - internal static string ReadmeNoFileElement - { - get - { + internal static string ReadmeNoFileElement { + get { return ResourceManager.GetString("ReadmeNoFileElement", resourceCulture); } } - + /// /// Looks up a localized string similar to Unknown schema version '{0}'.. /// diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx index 2693522521f..8475fef1fa3 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx @@ -1,17 +1,17 @@ - @@ -139,9 +139,6 @@ The package ID '{0}' contains invalid characters. Examples of valid package IDs include 'MyPackage' and 'MyPackage.Sample'. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The schema version of '{0}' is incompatible with version {1} of NuGet. Upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942. @@ -250,4 +247,4 @@ The element 'readme' cannot be empty. - + \ No newline at end of file diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf index f674a6b5e2f..3cc994c23ab 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf @@ -197,11 +197,6 @@ Soubor readme {0} v balíčku neexistuje. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. Neznámá verze schématu {0} diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf index 0f80cf8fa0d..730bb10ffcf 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf @@ -197,11 +197,6 @@ Die Infodatei "{0}" ist nicht im Paket vorhanden. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. Unbekannte Schemaversion "{0}". diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf index 0f352774eb3..2993670185c 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf @@ -197,11 +197,6 @@ No existe el archivo Léame "{0}" en el paquete. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. Versión de esquema desconocida '{0}'. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf index 36a35a31b23..3b111c5074d 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf @@ -197,11 +197,6 @@ Le fichier readme '{0}' n'existe pas dans le package. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. Version de schéma '{0}' inconnue. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf index 6c0f1e16e8c..bf6e42cd7a0 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf @@ -197,11 +197,6 @@ Il file leggimi '{0}' non esiste nel pacchetto. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. Versione dello schema '{0}' sconosciuta. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf index 7389d8a6694..bba4bdbdca4 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf @@ -197,11 +197,6 @@ Readme ファイル '{0}' がパッケージに存在しません。 - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. 不明なスキーマのバージョン '{0}' です。 diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf index f26a45a5e35..dee0c2ece12 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf @@ -197,11 +197,6 @@ 추가 정보 파일 '{0}'이(가) 패키지에 없습니다. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. 알 수 없는 스키마 버전 '{0}'입니다. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf index 3cbf258a3df..ba401d5a51b 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf @@ -197,11 +197,6 @@ Plik readme „{0}” nie istnieje w pakiecie. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. Nieznana wersja schematu „{0}”. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf index e7fc159392d..c93fff08e78 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf @@ -197,11 +197,6 @@ O arquivo Leiame '{0}' não existe no pacote. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. Versão de esquema '{0}' desconhecida. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf index 837ba46c2e7..da99e34dd72 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf @@ -197,11 +197,6 @@ Файл сведений "{0}" отсутствует в пакете. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. Неизвестная схема версии "{0}". diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf index d3f86f19365..d913c5b6055 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf @@ -197,11 +197,6 @@ '{0}' benioku dosyası pakette yok. - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. Bilinmeyen şema sürümü '{0}'. diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf index ea64811b3ad..1abf8711d0b 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf @@ -197,11 +197,6 @@ 包中不存在自述文件“{0}”。 - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. 未知的架构版本“{0}”。 diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf index 827afd625ac..d703812a21f 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf @@ -197,11 +197,6 @@ 讀我檔案 '{0}' 不存在於這個套件中。 - - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - The package ID '{0}' does not adhere to the restricted set of characters allowed in package IDs. Package IDs must start with a letter, digit, or underscore and contain only ASCII letters, digits, dots (.), and dashes (-) with no consecutive dots or dashes. Rename the package to use only characters from the restricted set. - - Unknown schema version '{0}'. 未知的結構描述版本 '{0}'。 From 3dbeea4e402935ab4a8bba53d2941ee8bcc701d3 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 24 Jun 2026 17:49:37 -0700 Subject: [PATCH 12/13] revert --- .../PackageCreation/Resources/xlf/NuGetResources.cs.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.de.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.es.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.fr.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.it.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.ja.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.ko.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.pl.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.ru.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.tr.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf | 2 +- .../PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf index 3cc994c23ab..54c7a0e6de6 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.cs.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf index 730bb10ffcf..546ba09874e 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.de.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf index 2993670185c..a7e3d819b77 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.es.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf index 3b111c5074d..5eba2cb4300 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.fr.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf index bf6e42cd7a0..2ab8c49957d 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.it.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf index bba4bdbdca4..7e908721833 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ja.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf index dee0c2ece12..dcbd98aaaa4 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ko.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf index ba401d5a51b..04fa894c35d 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pl.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf index c93fff08e78..0963afb6206 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.pt-BR.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf index da99e34dd72..b65e53748b8 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.ru.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf index d913c5b6055..3e28d6386b3 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.tr.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf index 1abf8711d0b..e6168f953f5 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hans.xlf @@ -1,4 +1,4 @@ - + diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf index d703812a21f..52250973502 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/xlf/NuGetResources.zh-Hant.xlf @@ -1,4 +1,4 @@ - + From a5f75a5ada727e2fb20ab835cbfd778a74450a0f Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Wed, 24 Jun 2026 17:49:55 -0700 Subject: [PATCH 13/13] more reverts --- .../Resources/NuGetResources.Designer.cs | 50 ++++++++++------- .../Resources/NuGetResources.resx | 56 +++++++++---------- 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs index a319570a210..6785129b920 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 @@ -19,7 +19,7 @@ namespace NuGet.Packaging.PackageCreation.Resources { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class NuGetResources { @@ -365,52 +365,62 @@ internal static string PackageAuthoring_FileNotFound { return ResourceManager.GetString("PackageAuthoring_FileNotFound", resourceCulture); } } - + /// /// Looks up a localized string similar to Cannot open the readme file '{0}': {1}.. /// - internal static string ReadmeCannotOpenFile { - get { + internal static string ReadmeCannotOpenFile + { + get + { return ResourceManager.GetString("ReadmeCannotOpenFile", resourceCulture); } } - + /// - /// Looks up a localized string similar to The readme file '{0}' is empty.. + /// Looks up a localized string similar to The readme file is empty.. /// - internal static string ReadmeErrorEmpty { - get { + internal static string ReadmeErrorEmpty + { + get + { return ResourceManager.GetString("ReadmeErrorEmpty", resourceCulture); } } - + /// - /// Looks up a localized string similar to The readme file '{0}' has an invalid extension. It must end in .md.. + /// Looks up a localized string similar to The readme file '{0}' has an invalid extension.. /// - internal static string ReadmeFileExtensionIsInvalid { - get { + internal static string ReadmeFileExtensionIsInvalid + { + get + { return ResourceManager.GetString("ReadmeFileExtensionIsInvalid", resourceCulture); } } - + /// /// Looks up a localized string similar to The element 'readme' cannot be empty.. /// - internal static string ReadmeMissingRequiredValue { - get { + internal static string ReadmeMissingRequiredValue + { + get + { return ResourceManager.GetString("ReadmeMissingRequiredValue", resourceCulture); } } - + /// /// Looks up a localized string similar to The readme file '{0}' does not exist in the package.. /// - internal static string ReadmeNoFileElement { - get { + internal static string ReadmeNoFileElement + { + get + { return ResourceManager.GetString("ReadmeNoFileElement", resourceCulture); } } - + /// /// Looks up a localized string similar to Unknown schema version '{0}'.. /// diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx index 8475fef1fa3..07fec34ec9c 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Resources/NuGetResources.resx @@ -1,17 +1,17 @@ - @@ -247,4 +247,4 @@ The element 'readme' cannot be empty. - \ No newline at end of file +