I just wondered if it possible within various Visual Studio versions to automatically remove all references from a project that were never been used?
In your answer,
The following method does not depend on any 'add-on's and is not very painful.
Step through each of your source files and
Scanning each file looking for '0 reference' takes only a second.
Scanning an entire project takes only a couple of minutes.
If you have Resharper (plugin) installed, you can access a feature that allows you to analyze used references via Solution Explorer > (right click) References > Optimize References...
http://www.jetbrains.com/resharper/webhelp/Refactorings__Remove_Unused_References.html
This feature does not correctly handle:
All you need is stone and bare knuckle then you can do it like a caveman.
You can also rely on your build tools to let you know which reference is still required. It's the era of VS 2017, caveman still survived.
For Visual Studio 2013/2015/2017 there is an extension that does exactly what you want: ResolveUR. What this basically does is:
With Visual Studio versions 2017 and 2015, you can do this with the Code Map feature, but this feature is only available in the Enterprise Edition, not the Community or Professional versions.
Right-click on the project node in the solution explorer and select 'Show on Code Map.' This will display your .dll as a single node in a blank graph. Right-click on that node in the Code Map and select "Show Assemblies This References." This will add an additional node called "Externals" which can be expanded to show only the assemblies that are actually referenced.
In Visual Studio 2013 this extension works: ResolveUR