Visual Studio project files are really just XML, so you could theoretically load the file as an XmlDocument
and select out all of the Reference
nodes that you find. This is an example of how my references are stored in a sample VB.net project file. I imagine it's not too different in a .csproj file:
<ItemGroup>
<Reference Include="System.Data.Linq" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Printing">
</ItemGroup>
Once you are able to do that, it would be pretty trivial to build out a collection of reference names from the values in the Include
attribute and then verify that it contains the references you are expecting.
Any explicit references that a project has are also implicit project depedencies. They are displayed, but not editable, in the Solution Properties window.
Edit
If you're looking for project dependencies for your solution, which were manually selected in addition to any explicit references you have, you can find those in the .sln file.
When you manually select a project dependency in the Solution Properties window, a ProjectSection(ProjectDependencies) section gets created inside of the Project's section.
For example, the following is a normal project entry in the .sln file:
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyProject",
"Source\MyProject\MyProject.vbproj",
"{AB5BA87B-77D5-4812-B02C-9B4FB87F4EF6}" EndProject
Here is what that project would look like if you were to manually add a project dependency later:
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyProject", "MyProject\MyProject.vbproj", "{AC1BE764-AC53-47B0-9608-648C28D3BB79}"
ProjectSection(ProjectDependencies) = postProject
{10F4313B-A586-4CC6-BAFE-51930EC8C68F} = {10F4313B-A586-4CC6-BAFE-51930EC8C68F}
EndProjectSection
EndProject
Notice the addition of the ProjectSection(ProjectDependencies)
Unfortunately, unlike the project file, the solution file is not XML. This would make parsing the file directly as text more difficult. Also, the projects inside the solution file are associated to GUIDs and any sections that reference them later use that GUID, and not the project name. This also makes things a bit more complicated as you must do a little preprocessing on the solution file to create a map of GUID to Project name. At that point you would be able to list out any explicit project dependencies from the solution file and compare if the ones that were added were the ones you expected to be added.