2016-07-07 4 views
0

私はEnvDTEを使用して、Visual StudioアドインでVCプロジェクトのリンカとコンパイラの設定/オプションを変更しています。しかし、私はDTEインスタンスからこれらのオプションにアクセスできる場所を見つけることができないようです。私が今までに持っているものはEnvDTEを使用してVCプロジェクトのリンカオプションを設定する方法

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

だから、どこでこれらのオプションを取得/設定できますか?

答えて

0

私がやりたいことやってEnvDTEと一緒にMicrosoft.VisualStudio.VCProjectEngineを使用して終了:

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; 
    } 
} 
関連する問題