Remove Unused References – Clean up project references and NuGet packages in Visual Studio

Remove Unused References – Clean up project references and NuGet packages in Visual Studio

You can now easily remove the unused references from your project or solution directly from the Visual Studio. Visual Studio allows “Remove Unused References” for any NuGet packages or projects which are not in use. This is extremely helpful in clean up project references. We add several NuGet Packages; some of them we used, some we just kept in explore state and not used in a real solution. Having these packages and project references unnecessarily increases your packages. So it is always better to clean up project references and NuGet packages that are not in used.

Remove Unused References

Clean up project references and NuGet Packages often more manageable when the solution is small, and we know precisely what has been used in the solution. For any large-scale solution, where several packages are in use, it’s quite difficult for a developer to find out them or could be time-consuming.

With the latest updates of Visual Studio, “Remove Unused References” is available. That makes developer jobs much easier than what it is used to be without using some other tools.

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.

CI/CD using GitHub Actions Workflow directly from Visual Studio

Did you know – Visual Studio can add Using directive automatically on paste?

Finally, Select “Apply” to remove all the references. Visual Studio will provide you a warning dialog that shows, “This action cannot be undone; do you wish to continue?

When there is no further unused references, if you select “Remove Unused References” you will have following dialog message.

To summarize, Removing unused references in Visual Studio is a great addition to clean up projects very quickly.

Learn Azure DevOps APIs: Exploring Azure DevOps APIs

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

One Comment to “Remove Unused References – Clean up project references and NuGet packages in Visual Studio”

Comments are closed.