管理外部工具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:

[屬性]Name 引數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 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