I want to know if any tool exists for removing unused references (not unused using
directives) within a .NET C# project.
In Solution Explorer, Right-click on the project. In this view, go to References, and remove the offending reference.
CTRL + K + E Will sort and remove your unused usings.
First is putting your cursor on one of the grayed out lines and clicking the light bulb, then clicking Remove Unnecessary Usings. (NOTE: The shortcut key for this is CTRL-.) When the action is executed the references will be cleaned up.
Clean up project references and NuGet packages in Visual Studio. Firstly, Right Click on the Project, and select “Remove Unused References”. This will bring up the “Remove Unused References” Dialog that shows the projects and all unused packages. Here, you can again choose if you want to remove them or keep it as it is ...
I am unaware of such a tool off the top of my head - I do know that Visual Studio does not include one by default. However, referenced assemblies that are not actually used by code in the project are automatically removed by the C# compiler from the list of assemblies referenced by the compiled program. If you use Reflector, you can compare the list of actual references to the list of references in the project, and remove the unnecessary ones that the project includes based on that.
Resharper will certainly do the trick...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With