Repository navigation
Warn when adding non-compliant package IDs - #7704
Merged
Merged
Conversation
Co-authored-by: Copilot <[email protected]>
Member
Author
jeffkl
approved these changes
Sep 15, 2026
baronfel
approved these changes
Sep 15, 2026
Nigusu-Allehu
approved these changes
Sep 15, 2026
zivkan
approved these changes
Sep 16, 2026
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Fixes: NuGet/Home#15076
Description
Adds a non-blocking warning when
dotnet package add(or itsdotnet add packagealias) successfully adds a directly requested package whose ID does not meet NuGet's restricted package-ID rules. This warns customers before they adopt a package ID that no longer meets NuGet's package-ID standard while preserving support for consuming existing legacy packages.This is a command-specific extension of the accepted package-ID design, which introduced the corresponding pack warning following NuGet/Announcements#75. It does not introduce a new validation policy.
Functional behavior
Compliant package IDs preserve the current output:
dotnet package add Contoso.UtilitiesA successfully added non-compliant direct package ID produces one warning:
The warning is emitted for the package ID supplied by the user only; the dependency graph is not scanned, so non-compliant transitive package IDs do not warn. Both command spellings use the same XPlat runner and therefore have identical behavior.
Implementation decisions
PackageIdValidator.IsValidPackageId(packageId, useRestrictedCharacterSet: true)so add-package and pack remain aligned on the validation rules.ILogger.LogWarning(string)without aNuGetLogCode. The warning cannot be suppressed throughNoWarn, promoted throughWarningsAsErrors, or converted to an error byTreatWarningsAsErrors.--no-restorepath emits it after the package reference is written. Failed resolution, compatibility checks, project updates, and restore commits do not produce a misleading warning.SdkAnalysisLevel. This is advisory interactive CLI output that cannot fail the operation, and gating--no-restorewould require loading the dependency graph on its current fast path solely to obtain SDK metadata.Testing
Adds unit coverage for compliant, non-ASCII, homoglyph, Japanese, trailing-separator, and package-ID length cases. Functional coverage verifies the
--no-restorepath, direct-versus-transitive scope, suppression on failed adds, and successful project updates whenTreatWarningsAsErrorsis enabled.Out of scope
Restore-time or transitive dependency warnings, changing pack warning
NU5052, blocking package consumption, warning suppression, Visual Studio or Package Manager Console behavior, anddotnet package update.PR Checklist