L_M
L_M

Reputation: 131

Read and change project properties "Start external program" and "command line arguments"

enter image description here

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.

Upvotes: 0

Views: 411

Answers (1)

Carlos Quintero
Carlos Quintero

Reputation: 4414

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.

Upvotes: 1

Related Questions