Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
Created October 3, 2012 12:19
Show Gist options
  • Select an option

  • Save DinisCruz/3826642 to your computer and use it in GitHub Desktop.

Select an option

Save DinisCruz/3826642 to your computer and use it in GitHub Desktop.
O2 Script - VisualStudio API - create top menu and hook build events
var visualStudio = new VisualStudio_2010();
//add a button called "My Custom Code" to the "Tools" Menu (at bottom), which when clicked will
//invoke the myCustomCode function which will show a WinForms MessageBox
Action myCustomCode = ()=>{
"This is custom code executing".messageBox();
};
var toolsMenu = visualStudio.dte().get_Menu("Tools");
toolsMenu.add_Menu_Button("My Custom Code", myCustomCode);
//Set up a callbacks on build begin and build OK
VisualStudio_2010.On_BuildBegin.add(
()=>{
visualStudio.errorList().clear()
.add_Message("There was a build");
});
VisualStudio_2010.On_ProjectBuild_OK.add(
(projectFile)=> {
visualStudio.errorList().add_Message("This project compliled OK: {0}".format(projectFile));
});
return visualStudio.dte();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment