0

Is there a way In a VSpackage to issue a clean on the project from code, to issue a rebuild or a build. So basically is there a way in code to call the commands that appears in the context menu when you left click on a project? (though my current context may not be in solution explorer I may be on the editor window, so calling ExecuteCommand wont work for commands that are only available when I am in the solution explorer)

enter image description here

Markus
  • 20,838
  • 4
  • 31
  • 55
Karim Tarabishy
  • 1,223
  • 1
  • 13
  • 25

1 Answers1

2

The SolutionBuild-interface offers various methods that allow performing actions on the solution, e.g. building the solution or a project and cleaning the solution.

You start at the DTE-object and access the SolutionBuild like this:

// Builds the solution and waits for the build to finish
DTE.Solution.SolutionBuild.Build(true); 
// Show result of build
MessageBox.Show(string.Format("{0} projects failed to build.", 
                   DTE.Solution.SolutionBuild.LastBuildInfo));
Markus
  • 20,838
  • 4
  • 31
  • 55