I have a Project
instance, and I don't understand how to find out the project type/language. Specifically, I need to check for a C/C++ project.
The docs seem lacking.
Previously, another person added the following bit of magic to my open-source VS extension, and it worked in VS2013-2015:
private static bool isVisualCppProject(object project)
{
Type projectObjectType = project.GetType();
var projectInterface = projectObjectType.GetInterface("Microsoft.VisualStudio.VCProjectEngine.VCProject");
return projectInterface != null;
}
...
isVisualCppProject(project.Object);
But it no longer works in VS 2017 RC. And I would gladly get rid of this runtime reflection magic and un-typed object
and dynamic
instead of Project
- the code is already getting unmaintainable because of this.
Kind
property(msdn.microsoft.com/en-us/library/envdte.project.kind.aspx) forenvdte.project
. It is GUID. There are predefined Project Kinds inPrjKind
(msdn.microsoft.com/en-us/library/vslangproj.prjkind.aspx) but it seems there is no property for c/c++. I guess you can get that GUID and it will be same for all c/c++ projects. – HebetudeKind
, but there's no list of possible "kinds", nor any guarantee that it is indeed static across various machines, installations and VS versions... – Preliminaries