How do I get ReSharper’s "Remove Unused References" feature to work on references added through NuGet packages?
Hi Everyone. I am using Visual Studio 2015 to work on a multi-project solution in C#. I have a NuGet package (made up of multiple common libraries developed internally) that is installed on all the projects within the solution. All the projects now have references to each DLL that was included in the package regardless of a DLLs actual use by the project. This simplifies managing references for approximately 50 projects since I can be sure each project has the references it needs. The plan was to then follow up with ReSharper to remove the unused references. Unfortunately, it doesn’t seem to work.
Here are things I tried:
- If I add a reference from the list of Assemblies in the Reference Manager, ReSharper can remove it.
- If I add a reference from the list of Projects in the References Manager, ReSharper may or may not remove it.
- If I add a reference by using the Browse feature in the References Manager, ReSharper may or may not remove it.
- If I add a NuGet package by context menu on either the solution or project, ReSharper cannot remove it.
- I tried editing the raw *.csproj project files to determine if there was any special difference in how assemblies were referenced when added as part of a NuGet package. I was unable to find a cause; changing the Reference element for assemblies from a NuGet package to look exactly like those added through various ways in Reference Manager yielded no change.
- I tried editing and finally deleting the packages.config file, which did nothing except tell the NuGet Package Manager that there were no packages installed. I repeated editing the *.csproj file after deleting the packages.config file, which still did not work.
- I couldn’t find any causes when experimenting with the reference properties in the Properties window of Visual Studio.
- I deleted the ReSharper caches, which did not solve the issue.
- Newly created projects have the same issue (ReSharper cannot remove references added by NuGet packages).
Here’s my setup:
- Microsoft Visual Studio Enterprise 2015 - 14.0.24720.00 Update 1
- NuGet Package Manager - 3.3.0
- ReSharper Ultimate - 10.0.2
Here is a link to the ReSharper help page for the feature: https://www.jetbrains.com/resharper/help/Refactorings__Remove_Unused_References.html
I’m running out of ideas for possible solutions and any help would be appreciated.
Thank you in advance!