How can you find unused NuGet packages in a solution?

How can you find unused NuGet packages in a solution?

I have a number of solutions in which there are many installed packages, and a large number are marked as having updates.

However, I am concerned that there may be a violation, so first I want to clean up by removing unused packages.

+91
visual-studio nuget
Nov 13 '13 at 10:27
source share
5 answers

ReSharper 2016.1 has the function of removing unused NuGet.

It can run on a solution and on every project in a solution, and it performs the following actions:

  • Analyze your code and collect assembly links.
  • Build a graph of NuGet usage based on the use of assemblies.
  • Packages without content files, unused and without dependencies are considered unused and are proposed to be removed.

Unfortunately, this does not work for project.json projects ( RSRP-454515 ) and major ASP.NET projects ( RSRP-459076 )

+41
Apr 15 '16 at 10:55
source share

You can use the Visual Studio ResolveUR extension - allow unused links

Allow unused links, including links to nuget in Visual Studio 2012/2013 projects, through the menu item in the solution and project nodes. Explorer Explorer tool window.

This is not an easy task, so I suggest making a backup and / or commit before doing this if something went wrong.

+18
Jul 01 '15 at 17:13
source share

You can accomplish this using Resharper 2018.1.

Right-click on the project> Refactoring> Delete Unused Links.

If your project is small, you can also> Analyze used links. ,,

A window will appear. Select all links and delete all of them. Then go back and add those again that give you a compiler error.

+1
Jun 14 '18 at 15:32
source share

I don’t think there is a standard way to find out. The main reason is that these packages can do different things: from the assembly link to the implementation of the source code in your project. You can check out Nuget.Extensions though. The following codeplex thread talks about the nuget package audit report.

http://nuget.codeplex.com/discussions/429694

(NuGet was moved from Codeplex to GitHub. Archive from the link above :) https://web.archive.org/web/20171212202557/http://nuget.codeplex.com:80/discussions/429694

0
Nov 16 '13 at 4:21
source share

This is manual labor, but it works.

  • Use the ReSharper tool or a similar code analysis tool to identify any unused links in your projects and remove nuget in their respective projects.

  • Sometimes deleted nugets are still delayed in the Installed packages and updates list in the NuGet Package Management dialog box. Close Visual Studio, then delete the packages folder, then open the solution again and restore your nugets.

0
Jan 25 '15 at 12:35
source share



All Articles