Remove unused references (!= “using”)

2019-01-13 02:11发布

How can I find and delete unused references in my projects?

I know you can easily remove the using statements in vs 2008, but this doesn't remove the actual reference in your projects. The referenced dll will still be copied in your bin/setup package.

11条回答
Luminary・发光体
2楼-- · 2019-01-13 02:21

I think that are copied in bin\, because in the project that removed the reference have reference o other project that have the same reference...

查看更多
Evening l夕情丶
3楼-- · 2019-01-13 02:23

If you know which references are not used you can remove them manually.
In Solution Explorer, right-click the reference in the References node, and then click Remove.

查看更多
别忘想泡老子
4楼-- · 2019-01-13 02:24

Removing unused references is a feature Visual Studio 2008 already supports. Unfortunately, only for VB .NET projects.

I have opened a suggestion on Microsoft Connect to get this feature for C# projects too:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=510326

If you like this feature as well then you might vote my suggestion.

查看更多
Fickle 薄情
5楼-- · 2019-01-13 02:27

Given that VisualStudio (or is it msbuild?) detects unused references and doesn't include them in the output file, you can write a script which parses the references out of the csproj, and compares that with the referenced Assemblies detected by reflexion on the project output.

If you're motivated...

查看更多
ゆ 、 Hurt°
6楼-- · 2019-01-13 02:29

I have a free answer that works in any version of Visual Studio and any Framework version. It doesn't remove the unused references, but it identifies them.

You can use Telerik JustDecompile on your project dll. Just open the dll in JustDecompile and go under References to see what is actually used in the compiled dll.

enter image description here

查看更多
不美不萌又怎样
7楼-- · 2019-01-13 02:30

I done this without extension in the VS 2010 Ultimate Architecture->Generate Dependency Graph->By Assembly, it shows used assemblies, and manually removed unused references.

查看更多
登录 后发表回答