Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

How to access project XML from a VS 2013 extension

$
0
0

I'm working on a Visual Studio extension that needs to directly modify a project's msbuild file (e.g. *.csproj). Unfortunately, the Visual Studio SDK doesn't seem to publicly expose any objects that support this.

If all else fails, I can always create a Microsoft.Build.Evaluation.Project object based on the file after a save event, make my edits there, then re-save. However, this would force the user to reload their project, which I'd prefer to avoid.

A better partial solution is described in this thread. Visual Studio keeps some of its evaluated objects in ProjectCollection.GlobalProjectCollection and smoothly detects any changes that I make via my extension. Unfortunately, this doesn't seem to work for all project types; it works great for C# but the global collection is left empty when I load a C++ project.

Does anyone know of a good, supported way to access the evaluated project objects? Failing that, is there a solution that doesn't involve forcing a project reload?

The extension needs to be compatible with Visual Studio 2013+ but doesn't need to support older versions.


Viewing all articles
Browse latest Browse all 4410

Trending Articles