Reading a list of links from the entire csproj project of sln solution (programmatically)

I have a sln solution that has many csproj projects.

Does anyone know a way to programmatically view the link list of all csproj projects in a VS2008 sln file?

+5
source share
2 answers

Csproj files are just XML files. For this, you can use XDocument from the .NET platform. I did this for VS2010, but in VS2008 the tags are almost the same.

Example for VS2010, you should check the tags and namespace:

XElement projectNode = XElement.Load(fileName);
XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";
var referenceNodes = projectNode.Descendants(ns + "ItemGroup").Descendants(ns + "Reference")

You can also check the ProjectReference tag. Hope this helps.

+3
source

, , Visual Studio, CodeModel API, addin :

Imports EnvDTE
Imports VSLangProj

Public Module Module1
    Public Sub ShowAllReferences()
        Dim sol As Solution = DTE.Solution
        For i As Integer = 1 To sol.Projects.Count
            Dim proj As Project = sol.Projects.Item(i)
            Dim vsProj As VSProject = DirectCast(proj.Object, VSProject)

            For Each reference As Reference In vsProj.References
                MsgBox(reference.Description)
            Next
        Next
    End Sub

End Module
+1

All Articles