2016-07-07 19 views
0

festlegen Ich verwende EnvDTE, um die Linker und Compiler-Einstellungen/Optionen eines VC-Projekts in einem Visual Studio-Add-In zu ändern. Aber ich kann nicht finden, wo ich auf diese Optionen von der DTE-Instanz zugreifen kann. Was ich bisher habe, istWie Sie Link-Optionen für VC-Projekt mit EnvDTE

// 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"); 
     } 
} 

Also, wo kann ich diese Optionen bekommen/setzen?

Antwort

0

landete ich mit EnvDTE mit Microsoft.VisualStudio.VCProjectEngine in Verbindung zu tun, was ich tun wollte:

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; 
    } 
}