How to convert from EnvDTE.Project to IVsHierarchy and IVsProject and viceversa

I've long been looking for an answer to how to go from an automation (DTE) project to its corresponding VSIP project instance. I've been given consistently the same non-satisfactory answer: there's no way because they are two fundamentally different object models that VSIP projects may or may not expose, and there's no consistent way of going from one to the other. Or that's what they said to me at the time.

As I'm not keen on accepting a "no" for an answer, I went on to investigate how to do it, and finally got to some working code that does it. It involves the DTE, VSIP and MSBuild. What follows is the code to achieve it...

2 Comments

  • Hiya,



    There is no code? :(



    I am trying to list the assemblies referenced in a project from a custom UITypeEditor, with no luck.



    I can get access to EnvDTE.Project but I need to convert or somehow get at the VSProject, not sure how...

  • You have to click on the entry title to go to the real entry where hte code lives.

    Getting from an EnvDTE.Project to a VSLangProj.VSProject is trivial, though, and not what I'm talking about in this post, which is about VSIP projects. You need to do the following:



    VSProject vsprj = theDteProject.Object as VSProject;

Comments have been disabled for this content.