You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warn when a package is referenced and is not a direct dependency #122
I would like an option to warn when something is referenced and it is not listed as a direct dependency and is instead being pulled in transitively.
This causes all kinds of problems when updating libraries that then pull in different versions of a transitive or even more unexpectedly when removing a direct dependency that shares a transitive dependency with another and then the version changes. Lock files don't help here, they only help when it is a direct dependency which this option would help to enforce.
For packagereferences i think one could achieve this by setting all packagereferences to PrivateAssets="compile" with an ItemDefinitionGroup. For ProjectReferences this can be achieved by setting <DisableTransitiveProjectReferences>.
Both of these have the caveat that it is not a warning but instead won't even compile if you use a dependency transitively.
Activity
janthomasQS commentedon Feb 4, 2026
For packagereferences i think one could achieve this by setting all packagereferences to PrivateAssets="compile" with an ItemDefinitionGroup. For ProjectReferences this can be achieved by setting
<DisableTransitiveProjectReferences>.Both of these have the caveat that it is not a warning but instead won't even compile if you use a dependency transitively.