I have a bundle of helper-method packed into an own class library (i.e. Tools.dll). When I start a new project I almost everytime reference this library. When Visual Studio compiles my new project I get a bunch of files in the bin\debug-folder. Of course there are "mynewproject.exe" and "Tools.dll" but since the helper-methods have own references I also find "HtmlAgilityPack.dll", "Scintilla.dll" etc. wheter I really used some of these functionalities or not. My question is: Can I get rid of them? If Visual Studio can filter them out themself, perfekt, if I have to do it manually at runtime, can you offer me an idea how to do that?
I did a lot of research but I can't find a method to analyse which dlls are used or to analyse at runtime which method calls which helper-method.
Thanks a lot!
Update to specify my idea: My idea was to run a script every time the program is started which checks which dll-files are there and then runs recursive through all methods to look which files are really needed. Then I could delete the unused dll-files. If that script needs to long I could additionally add a flag so this script has only to run once after every compiling.
If anyone has a better idea I'm of course interested :)
CodePudding user response:
If you want to know which dlls are used at runtime, maybe you can use the Reflection.
foreach (var item in Assembly.GetExecutingAssembly().GetReferencedAssemblies()) {
Console.WriteLine(item);
}
CodePudding user response: