I am currently working on a Visual Studio addin in Visual Studio 2015 which will retrieve the global include/library directories relevant to a loaded Visual C++ project.
According to the Microsoft Documentation, the VCDirectories
interface exists as a member of the Microsoft.VisualStudio.VCProject
namespace. However, I am having trouble accessing this interface when I have a valid VCProject reference in scope.
public List<string> IncludeDirectories()
{
List<string> includeDirs = new List<string>();
// assume VCProj() returns a valid VCProject object
VCProject proj = VCProj();
VCDirectories dirs = proj.VCDirectories;
return includeDirs;
}
From my understanding of the documentation, I should be able to reference the VCDirectories via proj
in the snippet above. But the VCDirectories
interface does not exist.
The full error reported by Visual Studio is; 'VCProject' does not contain a definition for 'VCDirectories' and no extension method 'VCDirectories' accepting a first argument of type 'VCProject' could be found (are you missing a using directive or an assembly reference?)
.
Can someone show me where I am going wrong?
Cheers
Edit
To complete the function above using information provided by Carlos;
public List<string> IncludeDirectories()
{
List<string> includeDirs = new List<string>();
// assume VCProj() returns a valid VCProject object
VCProject proj = VCProj();
VCPlatform pf = proj.ActiveConfiguration.Platform;
string[] directories = pf.Evalualte(pf.IncludeDirectories).split(';');
foreach(string dir in directories) {
if(dir != "") {
includeDirs.Add(dir);
}
}
return includeDirs;
}
You may want to use instead the following properties:
You can get the VCPlatform as I shown in the approach of this article some years ago:
HOWTO: Get standard include directories of Visual C++ project from an add-in
You can get the VCCLCompilerTool with the approach of this other article:
HOWTO: Get additional include directories of Visual C++ project from an add-in