You can do this using the UpToDate VCConfiguration property.
Assuming you can get an instance of EnvDTE.DTE , you can get the required VCProjectEngine VCConfiguration for the active project as follows: p>
public Project GetSolutionStartupProject(DTE dte) { string startupProjectName = String.Empty; SolutionBuild solutionBuild = dte.Solution.SolutionBuild as SolutionBuild; foreach (string item in solutionBuild.StartupProjects as Array) { startupProjectName += item; } return dte.Solution.Item(startupProjectName); } public void BuildStartupProject(DTE dte) { Project project = GetSolutionStartupProject(dte); Configuration activeConfiguration = project.ConfigurationManager.ActiveConfiguration;
If you want to make all the projects in a solution, it will be easier, since you do not need to look for a launch project. The important part is the conversion of the DTE Project instance to VCProjectEngine VCProject , looping VCConfigurations after you have it easy.
It is also worth noting that VCConfiguration.Build () will only build this configuration and crash if dependencies have not been created. You can use SolutionBuild.BuildProject () to create a project and its dependencies.
source share