Kiq*_*net 9 command visual-studio-2010 envdte
我使用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的可用命令的完整列表,任何官方文档都非常有用
有什么建议?
问题有点老了,但最近我遇到了同样的问题。我使用了EnvDTE.DTE的Commands集合(在此),可以在几行电源外壳中进行检索。正如您提到的,该列表很长,您可能需要过滤输出。
# 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()
Run Code Online (Sandbox Code Playgroud)