Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a list of projects/references within a Visual Studio 2010 Extension

I'm creating a Visual Studio 2010 extension package (Microsoft.VisualStudio.Shell.Package) that needs to analyze all of the projects and those project's references. I would assume that this is done with a service (e.g. Package.GetService(typeof(IMenuCommandService))). What I need is the interface that contains the functionality to get a list of projects and references for those projects. Also, any advice on where to find a reference that contains the available interfaces within visual studio would be much appreciated.

Note that I've seen multiple people trying to do something similar using DTE from a macro. That's not what I'm trying to do. I'm trying to do the same thing from within a Visual Studio Extension.

like image 850
Matt Ruwe Avatar asked May 13 '12 12:05

Matt Ruwe


1 Answers

So even though you're doing this as part of an extension, you'll still need to use the DTE APIs to get all of the information you want. It may seem backwards but that's just how it works. You should grab the DTE object via (EnvDTE.DTE)Package.GetService(typeof(SDTE)). Once you have a EnvDTE.Project, access it's Object member and cast that to a VSLangProj.VSProject if it's a C# or VB project. This has the reference information you need.

like image 112
Jason Malinowski Avatar answered Nov 15 '22 11:11

Jason Malinowski