How to get the Import elements for a given EnvDTE.Project? RRS feed

  • Question

  • I need to determine whether a given EnvDTE.Project imports a particular .targets file. I also need to add and remove Imports from projects.

    Currently, because I couldn't find a way to do this in the VS Extensibility API, I resorted to using the Microsoft.Build.Evaluation API to read/edit the project file on disk.

    There is an obvious down-side to this: I am reading and writing a version of the project that doesn't contain any in-memory edits, so could be out of date. Secondly, when I make a change, I trigger a fairly nasty "reload project" message box.

    So, I'm wondering where project imports info is exposed so I can read/modify the in-memory version of the loaded project. Does anyone know? I need to be able to read Imports that are not currently 'enabled' (i.e. their Condition may evaluate to false)

    Wednesday, December 17, 2014 2:31 PM