开发者

How do you determine which libraries are not being used

In developing a test project I've tried a lot of things which includes declaring an enormous amount of references/libraries. As a result I have a ton of declared libraries that are not being used in my project and would like to flush them out. Is there a way to know which libraries are not in use by the end product's code? I'm hoping there is some kind of visual studio function that can tell me thi开发者_如何学JAVAs.

Thanks!


Solution is handy. Just follow the link

How to: Remove Unused References

EDITED:

Since the above option is available only in VB.NET, you can go for some Visual Studio 2010 plug ins. Looks like Resharper does it. Please refer to Visual Studio: Detecting unneeded Assemblies for more detail.


Coderush is similar to Resharper, but they offer a free Xpress version on their website. You can go download that and it should show you which are unused (although I'm not 100% the Xpress version has this ability).


You can only easily find out what assemblies are used. Easy enough to invert the list. Look at the .assembly directives that the compiler put in the assembly manifest with ildasm.exe or Reflector. The compiler whittles down the list to assemblies that contains types that it encountered while compiling the code. Watch out for assemblies you load yourself.


In Visual Studio 2019 starting from the latest versions and Visual Studio 2022 you can remove unused packages, but only for SDK style projects. If you try on old projects, like .Net Framework, you won't see this option. As workaround, to verify, you can create two simply console apps: one using .Net Core or later, and one .Net Framework 4.7 or 4.8.

Just right-click on project name and select Remove Unused References


Please refer to: Remove Unused References

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜