Remove Unused References
This refactoring applies to:
- C#
- Visual Basic
What: For SDK style projects only, lets you remove unused references.
When: You want to clean up project references and NuGet packages that have no usage.
Why: Removing project references that have no usage can help save space and reduce startup time of your application, because it takes time to load each module and avoids having the compiler load metadata that will never be used.
Note
You can use the .NET Upgrade Assistant right from Visual Studio to upgrade your app to the latest .NET versions.
How-to
Verify that the option is enabled.
Select Tools > Options > Text Editor > C# > Advanced, and enable Show "Removed Unused References" command in Solution Explorer (experimental).
Right click on a project name or dependencies node in Solution Explorer.
Select Remove Unused References.
The Remove Unused References dialog will open displaying references that have no usage in source code. Unused references will be pre-selected for removal with an option to preserve references by selecting
Keep
from the Action drop down.Click
Apply
to remove selected references.