Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I followed @x0n's instructions but it didn't work out well for me. Maybe I was missing something. I have to admit that I could not load my <code>dll</code>s with <code>ReflectionOnlyLoad</code> because of a COM error. So I loaded them with <code>LoadFile</code>. The assembly references provided by <code>LoadFile</code> was exactly the same when I loaded the Assembly with Reflector. In the end my PowerShell script generated a list showing the references which are in the project but not loaded by the assembly. In theory these supposed to be the "unnecessary" references. When I started to remove them, the build failed. For example in case of my first project the lack of any of the 4 "unnecessary" references would cause the build to fail. I skim through the output of the powershell script and it lists "<code>System</code>" too for example. If I remove it the compiler doesn't even complain about a bunch of "<code>using System;</code>" but it fails before that - stating that I need to reference that assembly because of an interface... BTW, our project is not a toy, it involves 140+ dlls (almost half of which is Test <code>nUnit</code> dll though) and I thought I'll do some houskeeping. My script (which doesn't go recursively into project folders - some projects contain more dlls) so maybe someone can use it:</p> <p>`<br> $dte = [System.Runtime.InteropServices.Marshal]::GetActiveObject("visualstudio.dte")</p> <pre><code>$binfiles=Get-ChildItem C:\YourSourcePath\bin\debug $dlls=$binfiles | where { $_.extension -eq ".dll" -and $_.name -like "*YourCompanyName*" } foreach ($dll in $dlls) { foreach($prj in $dte.solution.projects) { if ($prj.Kind -eq "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") { if ($prj.Properties.Item("OutputFileName").Value -eq $dll.Name) { $loaded = [reflection.assembly]::LoadFile($dll.FullName) $refs = $loaded.GetReferencedAssemblies() Write "=============" Write $dll.Name Write "-------------" foreach($pref in $prj.Object.References) { $found = 0 foreach($ref in $refs) { if ($ref.Name -eq $pref.Name) { $found = 1 break; } } if ($found -eq 0) { Write $pref.Name } } } } } } </code></pre> <p>`</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload