2016-07-07 1 views
0

J'utilise EnvDTE pour modifier les paramètres et les options de l'éditeur de liens et du compilateur d'un projet VC dans un complément Visual Studio. Mais je n'arrive pas à trouver où je peux accéder à ces options depuis l'instance DTE. Ce que j'ai jusqu'à maintenant estComment définir les options de l'éditeur de liens pour le projet VC à l'aide d'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"); 
     } 
} 

Alors, où puis-je obtenir/définir ces options?

Répondre

0

Je fini par utiliser Microsoft.VisualStudio.VCProjectEngine conjointement avec EnvDTE faire ce que je voulais faire:

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