Replace DLL refs with Project refs for project dependencies in Visual Studio C# solution

Viewed 4540

Is it possible to programmatically replace DLL refs with Project refs for project dependencies in Visual Studio C#/VB.NET solution?

BACKGROUND:

I'm working with some legacy code where dependencies for each project are mostly referenced as compiled DLLs instead of including project reference from corresponding project in solution or even worse - referenced straight from GAC!

Right now I have to manually remove each DLL reference and replace it with project reference from VS UI for each solution out of dozens projects.

Editing the project/solution XML .csproj/.sln files is not straightforward due to GUIDs:

<!--typical DLL reference-->

<ItemGroup>
    <Reference Include="MyDLL, Version=2.0.1.0, Culture=neutral, PublicKeyToken=1b6d1e0267e1acba, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>...\MyDLL.dll</HintPath>
    </Reference>
</ItemGroup>

<!--typical Project reference-->

<ItemGroup>
    <ProjectReference Include="..\MyDLL\MyDLL.csproj">
      <Project>{3cc27830-3d6b-4071-85e5-5a4006f11142}</Project>
      <Name>MyDLL</Name>
    </ProjectReference>
</ItemGroup>
1 Answers
Related