Visual Studio 的開發人員命令提示字元Developer Command Prompt for Visual Studio

Visual Studio 的開發人員命令提示字元可讓您更輕鬆地使用 .NET Framework 工具。The Developer Command Prompt for Visual Studio enables you to use .NET Framework tools more easily. 它是命令提示字元,可自動設定特定的環境變數。It is a command prompt that automatically sets specific environment variables.

搜尋您電腦上的命令提示字元Search for the command prompt on your machine

根據您已安裝的 Visual Studio 及任何其他 SDK 版本,您可能會有多個命令提示字元。You may have multiple command prompts, depending on the version of Visual Studio and any additional SDKs you've installed. 例如,Visual Studio 64 位元版本提供 32 位元和 64 位元的命令提示字元 For example, 64-bit versions of Visual Studio provide both 32-bit and 64-bit command prompts. (大多數工具的 32 位元和 64 位元版本完全相同;然而,少數工具會分別變更 32 位元和 64 位元的環境)。如果下列步驟沒有作用,您可以嘗試以手動方式尋找您電腦上的檔案從 Visual Studio 內部執行命令提示字元(The 32-bit and 64-bit versions of most tools are the same; however, a few tools make changes specific to 32-bit and 64-bit environments.) If the following steps don't work, you can try Manually locate the files on your machine or Run the command prompt from inside Visual Studio.

在 Windows 10In Windows 10

  1. 在工作列的搜尋方塊中開始鍵入工具名稱,例如 devdeveloper command promptIn the search box on the taskbar, start typing the name of the tool, such as dev or developer command prompt. 這會顯示符合搜尋模式的已安裝應用程式清單。This brings up a list of installed apps that match your search pattern. 如果您要尋找不同的命令提示字元,請嘗試輸入不同的搜尋字詞,例如 promptIf you're looking for a different command prompt, try entering a different search term such as prompt.

  2. 選擇 [Visual Studio 開發人員命令提示字元] (或您想要使用的命令提示字元)。Choose the Developer Command Prompt for Visual Studio (or the command prompt you want to use).

在 Windows 8.1In Windows 8.1

  1. 按下 Windows 標誌鍵 鍵盤上的 Windows 標誌鍵 前往 [開始] 畫面。Go to the Start screen, by pressing the Windows logo key Windows logo key on the keyboard. 位於您的鍵盤上,作為範例。on your keyboard for example.

  2. 在 [開始] 畫面上,按 Ctrl + Tab 以開啟 [應用程式] 清單,然後輸入 VOn the Start screen, press Ctrl+Tab to open the Apps list, and then enter V. 這會顯示包含所有已安裝 Visual Studio 命令提示字元的清單。This brings a list that includes all installed Visual Studio command prompts.

  3. 選擇 [開發人員命令提示字元] (或您想要使用的命令提示字元)。Choose the Developer Command Prompt (or the command prompt you want to use).

在 Windows 8In Windows 8

  1. 按下 Windows 標誌鍵 鍵盤上的 Windows 標誌鍵 前往 [開始] 畫面。Go to the Start screen, by pressing the Windows logo key Windows logo key on the keyboard. 位於您的鍵盤上,作為範例。on your keyboard for example.

  2. 在 [開始] 畫面上,按下 Windows 標誌鍵 鍵盤上的 Windows 標誌鍵。On the Start screen, press the Windows logo key Windows logo key on the keyboard. + Z.+ Z.

  3. 選擇畫面底部的 [應用程式檢視] 圖示,然後輸入 VChoose the Apps view icon at the bottom of the screen and then enter V. 這會顯示包含所有已安裝 Visual Studio 命令提示字元的清單。This brings a list that includes all installed Visual Studio command prompts.

  4. 選擇 [開發人員命令提示字元] (或您想要使用的命令提示字元)。Choose the Developer Command Prompt (or the command prompt you want to use).

在 Windows 7In Windows 7

  1. 選擇 [開始],展開 [所有程式],然後展開 [Microsoft Visual Studio]。Choose Start, expand All Programs, and then expand Microsoft Visual Studio.

  2. 根據您已安裝的 Visual Studio 版本,請選擇 [Visual Studio Tools]、[Visual Studio 命令提示字元] 或您想要使用的命令提示字元。Depending on the version of Visual Studio you've installed, choose Visual Studio Tools, Visual Studio Command Prompt, or the command prompt you want to use.

如果已安裝 Windows 10 SDK舊版之類的其他 SDK,您可能會看到 ARM、x86 或 x64 架構的其他命令提示字元。If you have other SDKs installed, such as the Windows 10 SDK or previous versions, you may see additional command prompts for ARM, x86, or x64 architectures. 查看個別工具的文件以判斷要使用哪個版本的命令提示字元。Check the documentation for the individual tools to determine which version of the command prompt you should use.

以手動方式尋找您電腦上的檔案Manually locate the files on your machine

您已安裝之命令提示字元的捷徑通常會位於 Visual Studio 的 [開始功能表] 資料夾中,例如 C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools 中。Usually, the shortcuts for the command prompts you have installed are placed at the Start Menu folder for Visual Studio, such as in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools. 但如果基於某些原因,搜尋命令提示字元未產生預期的結果,您可以嘗試以手動方式尋找電腦上的捷徑。But if for some reason, searching for the command prompt doesn't bring the expected results, you can try to manually locate the shortcut on your machine. 嘗試搜尋 VsDevCmd.bat 等命令提示字元檔案名稱,或移至 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools 之類的 Tools 資料夾 (根據您的 Visual Studio 版本和安裝位置,這個路徑會變更)。Try searching for the name of the command prompt file, such as VsDevCmd.bat, or go to the Tools folder such as C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools (path changes according to your Visual Studio version, edition, and installation location).

從 Visual Studio 內部執行命令提示字元Run the command prompt from inside Visual Studio

為方便存取,您可以將 Visual Studio 開發人員命令提示字元或任何其他命令提示字元新增至 Visual Studio 的 [工具] 功能表。For easier access, you can add the Visual Studio Developer Command Prompt, or any other command prompt, to the Tools menu in Visual Studio. 若要讓工具可供使用,請將它新增至外部工具清單。To make the tool available, add it to the external tools list. 其步驟如下:Here are the steps:

  1. 開啟 Visual Studio。Open Visual Studio.

  2. 選取 [工具] 功能表,然後選擇 [外部工具]。Select the Tools menu, and then choose External Tools.

  3. 在 [外部工具] 對話方塊中,選擇 [加入] 按鈕。On the External Tools dialog box, choose the Add button. 新項目隨即出現。A new entry appears.

  4. 輸入新功能表項目的 [標題],例如 Command PromptEnter a Title for your new menu item such as Command Prompt.

  5. 在 [命令] 欄位中,指定您要啟動的檔案,例如 %comspec%C:\Windows\System32\cmd.exeIn the Command field, specify the file you want to launch, such as %comspec% or C:\Windows\System32\cmd.exe.

  6. 在 [引數] 欄位中,指定尋找所要使用之特定命令提示字元的位置,例如 /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat" (此命令會啟動隨 Visual Studio 2017 Enterprise 一起安裝的開發人員命令提示字元)。In the Arguments field, specify where to find the specific command prompt you want to use such as /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat" (this command launches the Developer Command Prompt that is installed with Visual Studio 2017 Enterprise). 根據您的 Visual Studio 版本和安裝位置變更這個值。Change this value according to your Visual Studio version, edition, and installation location.

  7. 選擇 [初始目錄] 欄位的值,例如 [專案目錄]。Choose a value for the Initial directory field, such as Project Directory.

  8. 選擇 [確定] 按鈕。Choose the OK button.

    這會新增功能表項目,而且您可以從 [工具] 功能表存取命令提示字元。The new menu item is added, and you can access the command prompt from the Tools menu.

    Visual Studio 中的命令提示字元功能表項目

另請參閱See also