Edit

Share via


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

  1. Verify that the option is enabled.

    Select Tools > Options > Text Editor > C# > Advanced, and enable Show "Removed Unused References" command in Solution Explorer (experimental).

  2. Right click on a project name or dependencies node in Solution Explorer.

  3. Select Remove Unused References.

    Remove Unused References command

  4. 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.

    Remove Unused References dialog

  5. Click Apply to remove selected references.

See also