0

I'm using EnvDTE to modify the linker and compiler settings/options of a VC project in a Visual Studio Add-in. But I can't seem to find where I can access these options from the DTE instance. 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?

rashmatash
  • 1,699
  • 13
  • 23

1 Answers1

1

I ended up using Microsoft.VisualStudio.VCProjectEngine in conjunction with EnvDTE to do what I wanted to do:

 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;
     }
}
rashmatash
  • 1,699
  • 13
  • 23