简体   繁体   中英

Read and change project properties “Start external program” and “command line arguments”

在此处输入图片说明

I'm trying to read (and change) the project properties "Start external program" and "Command line arguments" of a VisualStudio 2013 project within a VSPackage. The code I wrote so far looks like:

var dte = GetService(typeof(DTE)) as DTE2;
if (dte == null)
    return;

var sb = (SolutionBuild2)dte.Solution.SolutionBuild;
var projectNames = sb.StartupProjects as Array;
if (projectNames == null || projectNames.Length == 0)
  return;

var project = dte.Solution.Item(projectNames.GetValue(0));
var config = project.ConfigurationManager.ActiveConfiguration;

But I can't find the two spcific properties neither in the project nor in the config .

The EnvDTE.Configuration class has a Properties collection that has your desired values:

config.Properties.Item("StartProgram").Value

config.Properties.Item("StartArguments").Value

FWIW, the VSLangProj.dll assembly has a VSLangProj.ProjectConfigurationProperties class with the property names that you can expect in the config.Properties collection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM