Skip to content

Warn when a package is referenced and is not a direct dependency #122

Open

Description

@steinybot

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.

This is the exact opposite of #108.

I come from Scala where we have this sbt build plugin that enforces explicit and no unused dependencies: https://github.com/cb372/sbt-explicit-dependencies

Activity

  1. janthomasQS commented on Feb 4, 2026

    @janthomasQS

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions