管理外部工具Manage external tools

可以使用“工具”菜单从 Visual Studio 内部调用外部工具。You can call external tools from inside Visual Studio by using the Tools menu. “工具”菜单上提供了几个默认工具,但你也可以通过添加自己的其他可执行文件来自定义该菜单。A few default tools are available from the Tools menu, and you can customize the menu by adding other executables of your own.

“工具”菜单中提供的工具Tools available on the Tools menu

“工具”菜单包含若干内置命令,包括:The Tools menu contains several built-in commands, including:

将新工具添加到“工具”菜单Add new tools to the Tools menu

可以添加将在“工具”菜单中显示的外部工具。You can add an external tool to appear on the Tools menu.

  1. 通过选择“工具” > “外部工具”,打开“外部工具”对话框。Open the External Tools dialog box by choosing Tools > External Tools.

  2. 单击“添加”,然后填写信息。Click Add, and then fill in the information. 例如,以下条目会导致 Windows 资源管理器在当前已在 Visual Studio 中打开的文件目录中打开:For example, the following entry causes Windows Explorer to open at the directory of the file you currently have open in Visual Studio:

    • 标题:Open File LocationTitle: Open File Location

    • 命令:explorer.exeCommand: explorer.exe

    • 参数:/root, "$(ItemDir)"Arguments: /root, "$(ItemDir)"

    “外部工具”对话框

以下是在定义外部工具时可以使用的参数的完整列表:The following is a full list of arguments that can be used when defining an external tool:

nameName 参数Argument 说明Description
项路径Item Path $(ItemPath)$(ItemPath) 当前文件的完整文件名(驱动器 + 路径 + 文件名)。The complete file name of the current file (drive + path + file name).
项目录Item Directory $(ItemDir)$(ItemDir) 当前文件的目录(驱动器 + 路径)。The directory of the current file (drive + path).
项文件名Item File Name $(ItemFilename)$(ItemFilename) 当前文件的文件名(文件名)。The file name of the current file (file name).
项扩展名Item Extension $(ItemExt)$(ItemExt) 当前文件的文件扩展名。The file name extension of the current file.
当前行Current Line $(CurLine)$(CurLine) 代码窗口中光标的当前行位置。The current line position of the cursor in the code window.
当前列Current Column $(CurCol)$(CurCol) 代码窗口中光标的当前列位置。The current column position of the cursor in the code window.
当前文本Current Text $(CurText)$(CurText) 选定的文本。The selected text.
目标路径Target Path $(TargetPath)$(TargetPath) 要生成的项的完整文件名(驱动器 + 路径 + 文件名)。The complete file name of the item to be built (drive + path + file name).
目标目录Target Directory $(TargetDir)$(TargetDir) 要生成的项的目录。The directory of the item to be built.
Target NameTarget Name $(TargetName)$(TargetName) 要生成的项的文件名。The file name of the item to be built.
目标扩展名Target Extension $(TargetExt)$(TargetExt) 要生成的项的文件扩展名。The file name extension of the item to be built.
二进制目录Binary Directory $(BinDir)$(BinDir) 正在生成的二进制文件的最终位置(定义为驱动器 + 路径)。The final location of the binary that is being built (defined as drive + path).
项目目录Project Directory $(ProjectDir)$(ProjectDir) 当前项目的目录(驱动器 + 路径)。The directory of the current project (drive + path).
项目文件名Project File Name $(ProjectFileName)$(ProjectFileName) 当前项目的文件名(驱动器 + 路径 + 文件名)。The file name of the current project (drive + path + file name).
解决方案目录Solution Directory $(SolutionDir)$(SolutionDir) 当前解决方案的目录(驱动器 + 路径)。The directory of the current solution (drive + path).
解决方案文件名Solution File Name $(SolutionFileName)$(SolutionFileName) 当前解决方案的文件名(驱动器 + 路径 + 文件名)。The file name of the current solution (drive + path + file name).

Note

IDE 状态栏会显示“当前行”和“当前列”变量,用于指示插入点在活动代码编辑器中的位置。The IDE status bar displays the Current Line and Current Column variables to indicate where the insertion point is located in the active Code Editor. “当前文本”变量返回在该位置选择的文本或代码。The Current Text variable returns the text or code selected at that location.

请参阅See also