[英]How to set linker options for VC project using EnvDTE
I'm using EnvDTE to modify the linker and compiler settings/options of a VC project in a Visual Studio Add-in. 我正在使用EnvDTE修改Visual Studio加载项中VC项目的链接器和编译器设置/选项。 But I can't seem to find where I can access these options from the DTE instance. 但是我似乎找不到从DTE实例访问这些选项的位置。 What I have so far is 我到目前为止所拥有的是
// I successfully can open the solution and get the project I'd like to
// modify the build options of (compiler and linker options)
foreach (EnvDTE.Project p in VS2015Instance.Solution.Projects)
{
if(p.UniqueName.Contains(projectName))
{
// At this point I have a reference to my VC project.
// Here I'd like to set some linker option before building the
// project.
VS2015Instance.ExecuteCommand("Build.BuildSolution");
}
}
So, where can I get/set these options? 那么,我在哪里可以获得/设置这些选项?
I ended up using Microsoft.VisualStudio.VCProjectEngine
in conjunction with EnvDTE
to do what I wanted to do: 我最终将Microsoft.VisualStudio.VCProjectEngine
与EnvDTE
结合使用来完成我想做的事情:
VCLinkerTool linker;
foreach (EnvDTE.Project p in VS2015Instance.Solution.Projects)
{
if (p.UniqueName.Contains(project.Name))
{
var prj = (VCProject)p.Object;
var cfgs = (IVCCollection)prj.Configurations;
foreach (VCConfiguration cfg in cfgs)
{
if (cfg.ConfigurationName.Contains("Debug"))
{
var tools = (IVCCollection)cfg.Tools;
foreach (var tool in tools)
{
if (tool is VCLinkerTool)
{
linker = (VCLinkerTool)tool;
// now I can use linker to set its options.
break;
}
}
break;
}
}
break;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.