Find out all nuget pkgs not used by the project.

Topics: Ecosystem, General
Jan 15, 2013 at 5:51 PM

All,

We have more that 20 nuget pkgs added to our project, was wondering if there is a command that is out there that will list out all pkgs that are not used and a way to remove them ?

Thanks -Madhu

Jan 21, 2013 at 7:23 PM

I don't think it exists. One reason it might not be a great feature to have is that it would be hard to really get right. If it only worked based on assembly depenencies it would report false positive for packages which don't include assemblies but include scripts or source code, or other files/resources, etc.
Tim

Jan 28, 2013 at 11:09 PM

Should have a tool ready for this in the coming weeks.  Feel free to pitch in and help if you are interested.  There is a case for false positives, but on the whole the aim is to have it run in two modes:

  1. Audit and report, but no changes (this will probably be the first version out, and is pretty close to testable).
  2. Audit, report and fix.  This would give the option to remove unused references from the .csproj (based on runtime transitive or not), and remove unused packages from the packages.config.

We already have a tool we use for auditing an entire feed for package sanity which:

  1. Checks to ensure that all packaged assemblies have their manifest dependencies met by either
    1. Included assemblies
    2. Package Dependencies
  2. Ensures that all referenced package dependencies exist on the feed
  3. (Few other random checks I cant remember!)

If you want to take a look, check here: http://github.com/BenPhegan/NuGet.Extensions with the code for the Solution Audit in a branch called SolutionAudit.

We currently only build against NuGet 1.7 (I know....I know...) but will be looking to upgrade dependency soon.