Removing unused Nuget Packages

After working with Visual Studio and R# for many years now I discovered this feature just yesterday. Maybe some of you find it useful too.
I removed code that was depending on an external Nuget Package. Because the code is gone my project didn’t need the Nuget Package anymore. How to fast and safely remove the references and the package?
Let’s check the currently installed packages first:
Instead of opening the Nuget Packagemanager and uninstalling things manually there is faster way: right click on the project in the Solution Explorer and go into R# Refactor menu. There you’ll find the Remove unused references menu item.
This command will show you a dialog where one not only can select the plain assembly references to remove but also the references that come from a installed Nuget Package. This dialog shows a different icon for package references. See the highlighted item.
Clicking next will remove the selected references. For references that where introduced by an installed package the package is uninstalled too. Means your package folder is cleaned and the package is also removed from the package.config / .csproj.
The following show that not only the reference but also the package was removed:
Its a nice timesaver!
Categories
Does it works for .NET Framework, .NET Core and .NET Standard ?
LikeLike
Can’t find “Refactor” menu item… Which Visual Studio does your article apply for? Tsk. Define your terms mate!
LikeLike
It’s Resharper
LikeLike