C# Visual Studio SDK:VCDirectories 接口
C# Visual Studio SDK: VCDirectories interface
我目前正在 Visual Studio 2015 年开发一个 Visual Studio 插件,它将检索与加载的 Visual C++ 项目相关的全局 include/library 目录。
根据 Microsoft Documentation,VCDirectories
接口作为 Microsoft.VisualStudio.VCProject
命名空间的成员存在。但是,当我在范围内有一个有效的 VCProject 引用时,我无法访问此接口。
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;
}
根据我对文档的理解,我应该能够通过上面代码段中的 proj
引用 VCDirectories。但是VCDirectories
接口不存在
Visual Studio 报告的完整错误是; '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?)
.
谁能告诉我哪里出错了?
干杯
编辑
利用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;
}
您可能想改用以下属性:
你可以按照我几年前这篇文章的方法获得VCPlatform:
HOWTO: Get standard include directories of Visual C++ project from an add-in
您可以通过这篇文章的方法获取VCCLCompilerTool:
HOWTO: Get additional include directories of Visual C++ project from an add-in
我目前正在 Visual Studio 2015 年开发一个 Visual Studio 插件,它将检索与加载的 Visual C++ 项目相关的全局 include/library 目录。
根据 Microsoft Documentation,VCDirectories
接口作为 Microsoft.VisualStudio.VCProject
命名空间的成员存在。但是,当我在范围内有一个有效的 VCProject 引用时,我无法访问此接口。
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;
}
根据我对文档的理解,我应该能够通过上面代码段中的 proj
引用 VCDirectories。但是VCDirectories
接口不存在
Visual Studio 报告的完整错误是; '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?)
.
谁能告诉我哪里出错了?
干杯
编辑
利用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;
}
您可能想改用以下属性:
你可以按照我几年前这篇文章的方法获得VCPlatform:
HOWTO: Get standard include directories of Visual C++ project from an add-in
您可以通过这篇文章的方法获取VCCLCompilerTool:
HOWTO: Get additional include directories of Visual C++ project from an add-in