将项添加到AddIn中的visual studio文件夹右键菜单

我想在visual studio 2012解决方案资源管理器中右键单击=>添加菜单添加一个menuitem。 单击自定义项目时,我可以使用我的模板添加项目。 我开发了一个Visual Studio加载项来实现它,但是我遇到了一些麻烦。 我可以在右键菜单中添加一个menuitem,但我无法满足我的要求。

  1. menuitem应该是“Add”的子菜单。 不是根项目。

  2. 我还需要menuitem才能在我右键单击名为“Areas”的文件夹时显示。 当我右键单击其他文件夹时,我不希望它显示。

这是我的OnConnectionfunction代码。 如何更改它以满足我的要求。

 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) { object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)_applicationObject.Commands; //Place the command on the tools menu. //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items: var bars=((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars); Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = bars["MenuBar"]; //Find the Tools command bar on the MenuBar command bar: //CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName]; //CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl; // get popUp command bars where commands will be registered. CommandBars cmdBars = (CommandBars)(_applicationObject.CommandBars); //CommandBar vsBarItem = cmdBars["Item"]; //the pop up for clicking a project Item CommandBar vsBarFolder = cmdBars["Web Project Folder"]; CommandBar vsBarWebFolder = cmdBars["Web Folder"]; //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in, // just make sure you also update the QueryStatus/Exec method to include the new command names. try { //Add a command to the Commands collection: Command command = commands.AddNamedCommand2(_addInInstance, "ModuleAddin", "Add a Project", "Executes the command for ModuleAddin", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); //Add a control for the command to the tools menu: if (command != null) { //command.AddControl(toolsPopup.CommandBar, 1); command.AddControl(vsBarFolder); //CommandBarButton button = (CommandBarButton)command.AddControl(vsBarFolder, 3); //button.BeginGroup = true; } } catch (System.ArgumentException argEx) { System.Diagnostics.Debug.Write("Exception in HintPaths:" + argEx.ToString()); } } } 

您不需要加载项。

我是否真的要复制某人的博客post,所以我不会因为发布有用的链接而被投票? 你们这些人都知道archive.org ,对吗?

链接: http : //nickmeldrum.com/blog/how-to-run-powershell-scripts-from-solution-explorer-in-visual-studio-2010

复制粘贴博客post……

第1步:添加“运行powershell脚本”作为外部工具

  1. 在Visual Studio中,转到菜单:工具| 外部工具
  2. 单击“添加”按钮
  3. 添加以下表单值:

    • 标题:“在输出窗口中运行Powershell脚本”
    • 命令:“C:\ windows \ system32 \ windowspowershell \ v1.0 \ powershell.exe”
    • 参数:“ – file”$(ItemPath)“
    • 初始目录:“$(ItemDir)”
    • 勾选“使用输出窗口”
    • (退出时关闭现在将自动开启)
  4. 单击“应用”按钮

  5. 单击“添加”按钮

  6. 添加以下表单值:

    • 标题:“在VS之外运行powershell脚本”
    • 命令:“C:\ windows \ system32 \ windowspowershell \ v1.0 \ powershell.exe”
    • 参数:“ – file”$(ItemPath)“
    • 初始目录:“$(ItemDir)”
    • 不要勾选“使用输出窗口”
    • 勾选“退出时关闭”
  7. 单击“确定”按钮

他们应该看起来像这样: />“> </p>
<h1> 第2步:奇怪的一步,相信我! </h1>
<p> 检查它在外部工具列表中的索引位置。 默认情况下,我在第6和第7位。(我认为默认情况下创建GUID是第1位!) </p>
<h1> 第3步:将其连接到上下文菜单 </h1>
<ol>
<li> 转到菜单:工具| 自定义| 命令 </li>
<li> 单击“上下文菜单”单选选项 </li>
<li> 向下滚动到“项目和解决方案上下文菜单|项目”(梦魇长菜单,键入“Proj”以大致到达正确的位置) </li>
<li> 单击“添加命令”按钮 </li>
<li> 选择类别:“工具”和命令:“外部命令7”(或者您从“奇怪的第2步”获得的位置) </li>
<li> 点击“确定”按钮 </li>
<li> 然后设置第二个命令: </li>
<li> 选择类别:“工具”和命令:“外部命令8”(或任何你的位置是另一个) </li>
<li> 再次点击“确定”按钮 </li>
<li> 移动它们直到你对他们的订单感到满意(我通常将它们放在“打开方式……”下面的某处) <img src=