views:

1547

answers:

4

I'm working with a large (270+ project) VS.Net solution. Yes, I know this is pushing the friendship with VS but it's inherited and blah blah. Anyway, to speed up the solution load and compile time I've removed all projects that I'm not currently working on... which in turn has removed those project references from the projects I want to retain. So now I'm going through a mind numbing process of adding binary references to the retained projects so that the referenced Types can be found.

Here's how I'm working at present;

  • Attempt to compile, get thousands of errors, 'type or namespace missing'
  • Copy the first line of the error list to the clipboard
  • Using a perl script hooked up to a hotkey (AHK) I extract the type name from the error message and store it in the windows clipboard
  • I paste the type name into source insight symbol browser and note the assembly containing the Type
  • I go back to VS and add that assembly as a binary reference to the relevant project

So now, after about 30 mins I'm thinking there's just got to be a quicker way...

+2  A: 

These solutions come to my mind:

  • You can try to use Dependency Walker or similar program to analyze dependecies.
  • Parse MSBuild files (*.csproject) to get list of dependencies

EDIT:
Just found 2 cool tools Dependency Visualizer & Dependency Finder on codeplex I think they can help you greatly.

EDIT:
@edg, I totally misread your question, since you loose references from csproj files you have to use static analysis tool like NDepend or try to analyze dependencies in run time.

aku
Yeah cool, and thanks for your suggestions. Scanning the csproj will only work if the references exist already, which they don't in my case. And scanning the DLL using a tool like depends.exe is no better than using source insight. Thanks anyway.
Ed Guiness
Yep, I misread your question, I apology. Did you try to analyze dependencies in run-time using Dependency Walker?
aku
+1  A: 

One thing you can try is opening up the old .csproj file in notepad and replacing the ProjectReference tags with Reference tags. If you can write a parser, feel free to share. :)

Entry in .csproj file if it is a project reference

  <ItemGroup>
    <ProjectReference Include="..\WindowsApplication2\WindowsApplication2.csproj">
      <Project>{7CE93073-D1E3-49B0-949E-89C73F3EC282}</Project>
      <Name>WindowsApplication2</Name>
    </ProjectReference>
  </ItemGroup>

Entry in .csproj file if it is an assembly reference

  <ItemGroup>
    <Reference Include="WindowsApplication2, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <ExecutableExtension>.dll</ExecutableExtension>
      <HintPath>..\WindowsApplication2\bin\Release\WindowsApplication2.dll</HintPath>
    </Reference>   </ItemGroup>
Gulzar
+1  A: 

No, there's currently built-in quicker way.

I would suggest not modifying the existing solution and create a new solution with new projects that duplicate (e.g. rename and edit) the projects you want to work on. If you find that the solution with the hundreds of projects is an issue for you then you'll likely just need to work on a subset. Start with a couple of new projects, add the binary (not project) reference and go from there.

Peter Ritchie
+1  A: 

Instead of removing the project files from the solution, you could unload the projects you aren't working on (right-click the project and select Unload Project). As long as the unloaded project has been built once, any other project with a reference to it will be able to find the assembly in the project's output directory and build with it.

Emperor XLII