Time for some more fun with VisualStudio macros.
Lets consider this common scenario: You open a project to make a minor adjustment and then realize that in order to compile that project, you need to add all the dependencies (project references) to your solution. For larger projects, that could be a LOT of projects to add… AND you may have to do this recursively! take a look at the reference, locate the project file, add it to your solution, repeat. Since I am indeed THAT lazy, I created a macro to do that for me.
Since I couldn’t find any API that could help me figure out which references are unresolved or where to find the project files, my macro mostly operates on project file level. It opens the project files (XML), locates the project reference items and checks each reference against the currently loaded projects. If the reference is not in the solution yet, it adds the project and recursively resolves its references. It’s not exactly pretty, but it does get the job done =)
To use the macro, simply create a new macro module in the Macro IDE and paste the code from the attached document (you will probably have to update your macro project references to include System.Xml).