Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should be able to do this with just plain powershell:</p> <p>1) load visual studio with your solution</p> <p>2) compile entire solution</p> <p>3) leave VS running and start powershell.exe</p> <p>4) grab a reference to the still running instance of VS's DTE from the ROT (important - ensure only one instance running - if its elevated, powershell should be too):</p> <pre><code>ps&gt; $dte = [System.Runtime.InteropServices.Marshal]::GetActiveObject("visualstudio.dte") </code></pre> <p>5) Test by enumerating all projects in the solution with their references:</p> <pre><code>ps&gt; $dte.solution.projects | select @{l="name";e={$_.name}}, ` @{l="references";e={$_.object.references|select -exp name}} | ft -auto </code></pre> <p>... dumps all project names and references ...</p> <p>6) Now, write some script to traverse the solution folder and projects</p> <p>7) when you hit the bin\ folder, load up the assembly with reflection only load:</p> <pre><code>$assembly = [reflection.assembly]::reflectiononlyload($dll) </code></pre> <p>8) get the <em>actual</em> referenced assemblies in your output assembly</p> <pre><code>$refs = $assembly.getreferencedassemblies() </code></pre> <p>9) compare the <em>actual</em> referenced assemblies to the assemblies referenced in the project and remove the redundant ones via the VS DTE object model</p> <pre><code># example $currentproj.object.references.item("system.core").remove() $currentproj.save() </code></pre> <p>10) profit!</p> <p>This works because .net only links assemblies that are actually referenced in the code. Sorry I can't post a full working example but this should be enough to get you started.</p> <p>-Oisin</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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