I'm messing around with Visual Studio (2008) add-ins. I want to be able to add a button to all web application context menus (that will setup IIS for the website based on a shared archive from the web deployment tool).
I've got as far as being able to add the context item on the project context menu:
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{ applicationObject = (DTE2)application; addInInstance = (AddIn)addInInst;
if (connectMode == ext_ConnectMode.ext_cm_UISetup) {
var contextGuids = new Object[] {};
var iisSetupCommand = applicationObject.Commands.AddNamedCommand(
addInInstance,
CommandNameSetupIis,
"Setup IIS",
"Create the bindings in IIS for the website. Requires an IIS folder in the project root with the archive xml files for the website.",
true,
52,
ref contextGuids,
(int) vsCommandStatus.vsCommandStatusSupported + (int) vsCommandStatus.vsCommandStatusEnabled
);
var commandBars = (CommandBars) applicationObject.CommandBars;
var projectMenu = commandBars["Project"];
iisSetupCommand.AddControl(projectMenu, projectMenu.Controls.Count + 1);
}
}
This works, but I'm having trouble getting further.
Problem 1 is the button disappears when clicked.
Problem 2 is I have no idea how to only show the button for web application projects.
Problem 3 is I then need to write the code to grab the iis archive, the current project directory path and the project name to create the IIS bindings and then run the web deployment tool with these settings.
This add-in stuff is very obtuse. I've googled as much as I can and read most of the (terrible) msdn documentation. The best info I found was: http://dotnetslackers.com/articles/vs_addin/Lessons_learned_from_Copy_to_Html_Add_in.aspx
Can anyone help?