【问题标题】:Get full list of available commands for DTE.ExecuteCommand获取 DTE.ExecuteCommand 可用命令的完整列表
【发布时间】:2012-12-13 07:58:00
【问题描述】:

我使用 VS2010 和 Addin,使用 DTE.ExecuteCommand 和 Build、Build.Cancel、Build.RebuildSolution 等命令。

您可以使用 DTE.Commands.Item("xxx") 获取命令并猜测是否可以使用 Command.IsAvailable。命令列表位于工具、选项窗口、环境、键盘部分。

同样,如您所知,DTE.ExecuteCommand 将两个字符串作为参数。

第一个是命令的名称(例如,Action.CreateNewShortcut),第二个是命令采用的参数。

问题是某些命令需要可变数量的参数,我不知道顺序等。

例如,我猜 Action.CreateNewShortcut 至少需要两个参数:执行快捷方式时要运行的操作 (Build.RebuildSolution) 和快捷方式本身 (Alt+O)。

VS 中有超过 4k 条命令。但我认为微软还没有关于它的官方文档。

任何带有 DTE.ExecuteCommand 可用命令的完整列表的官方文档都会非常有用

有什么建议吗?

【问题讨论】:

    标签: visual-studio-2010 command envdte


    【解决方案1】:

    可以按照以下过程检查命令列表:

    • 打开 Visual Studio 的Options Dialog Box
    • 选择环境/键盘页面
    • 您可以在“显示包含:的命令”框中搜索特定命令,或者直接滚动其后面的列表。

    【讨论】:

      【解决方案2】:

      您可以使用即时窗口来执行此操作。只需输入“>”并开始输入命令。

      【讨论】:

        【解决方案3】:

        问题有点老了,但我最近遇到了同样的问题。我使用了来自 EnvDTE.DTE (here) 的 Commands 集合,它可以在几行 power shell 中检索到。正如您提到的,列表很长,您可能需要过滤输出。

        # Get Visual Studio 2015 type
        # -- find other version in registry HKEY_CLASSES_ROOT\VisualStudio.DTE.x.x
        $type = [System.Type]::GetTypeFromProgID("VisualStudio.DTE.14.0")
        # Create an instance of EnvDTE.DTE - actually launches a devenv.exe process
        $dte = [System.Activator]::CreateInstance($type,$true)
        # list of Commands is output simply when typing : Can be very long
        $dte.Commands
        # Will output the name of the command, its GUID and other attributes
        # Close process when done
        $dte.Quit()
        

        【讨论】:

        • 这可以直接通过 VS 中的包管理器控制台来完成,因为它提供了一个 $dte 实例,而无需为正确的类型剔除注册表。工作于 2015 年和 2017 年。
        【解决方案4】:
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-10
        • 1970-01-01
        • 2014-12-29
        • 2012-12-15
        • 2020-06-03
        相关资源
        最近更新 更多