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

Visual Studio 的開發人員命令提示字元可讓您更輕鬆地使用 .NET Framework 工具。Developer Command Prompt for Visual Studio enables you to use .NET Framework tools more easily. 它是自動設定特定環境變數的命令提示字元。It's a command prompt that automatically sets specific environment variables. 開啟開發人員命令提示字元之後,您可以輸入.NET Framework 工具的命令,例如 ildasmclrverAfter opening Developer Command Prompt, you can enter the commands for .NET Framework tools such as ildasm or clrver.

必要條件:Prerequisites

搜尋您電腦上的命令提示字元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 and workloads you've installed. 如果下列步驟沒有作用,您可以嘗試以手動方式尋找您電腦上的檔案,或從 Visual Studio 內啟動命令提示字元。If the following steps don't work, you can try to manually locate the files on your machine or start the command prompt from inside Visual Studio.

Windows 10Windows 10

  1. 選取鍵盤上的 啟動![Windows 標誌鍵]。Select Start Windows logo key on the keyboard. 並滾動到字母Vand scroll to the letter V.

  2. 展開 [ Visual Studio 2019 ] 資料夾。Expand the Visual Studio 2019 folder.

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

    或者,您可以在工作列的 [搜尋] 方塊中,開始輸入命令提示字元的名稱,然後選擇您想要的結果,因為結果清單會開始顯示搜尋相符專案。Alternatively, you can start typing the name of the command prompt in the search box on the taskbar, and choose the result you want as the result list starts to display the search matches.

    顯示 Windows 10 搜尋行為的動畫 gif

Windows 8.1Windows 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+ 索引標籤以開啟 應用程式清單,然後按V。這會顯示一份清單,其中包含所有已安裝的 Visual Studio 命令提示字元。On the Start screen, press Ctrl+Tab to open the Apps list, and then press V. This brings up a list that includes all installed Visual Studio command prompts.

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

Windows 7Windows 7

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

  2. 針對 VS 2019選擇Visual Studio 2019 > Visual Studio Tools > 開發人員命令提示字元或您想要使用的命令提示字元。Choose Visual Studio 2019 > Visual Studio Tools > Developer Command Prompt for VS 2019, or the command prompt you want to use.

    已反白顯示命令提示字元的 Windows 7 [開始] 功能表

如果您已安裝其他 Sdk (例如Windows 10 SDK舊版),您可能會看到其他的命令提示字元。If you have other SDKs installed, such as the Windows 10 SDK or previous versions, you may see additional command prompts. 查看個別工具的文件以判斷要使用哪個版本的命令提示字元。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 的 [開始功能表] 資料夾中,例如 %ProgramData%\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019 \ Visual Studio ToolsUsually, the shortcuts for the command prompts you have installed are placed at the Start Menu folder for Visual Studio, such as in %ProgramData%\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools. 但如果基於某些原因,搜尋命令提示字元並不會產生預期的結果,您可以嘗試在您的電腦上手動找出快捷方式。But if, for some reason, searching for the command prompt doesn't produce the expected results, you can try to manually locate the shortcut on your machine. 請嘗試搜尋命令提示字元檔案的名稱(例如vsdevcmd.bat),或移至 [工具] 資料夾,例如 % ProgramFiles (x86)% \ Microsoft Visual Studio\2019\Community\Common7\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 %ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools (path changes according to your Visual Studio version, edition, and installation location).

從內部啟動命令提示字元 Visual StudioStart the command prompt from inside Visual Studio

為方便存取,您可以將開發人員命令提示字元或任何其他命令提示字元新增至 Visual Studio 中的 [工具] 功能表。For easier access, you can add 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. 在 [開始] 視窗中,選擇 [不使用程式碼繼續]。On the start window, choose Continue without code.

  3. 在功能表列上,選擇 [工具] > [外部工具]。On the menu bar, choose Tools > External Tools.

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

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

  6. 在 [命令] 欄位中,指定您要啟動的檔案,例如 %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.

  7. 在 [引數] 欄位中,指定要在哪裡尋找您要使用的特定命令提示字元,例如 /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"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\2019\Community\Common7\Tools\VsDevCmd.bat". 此命令會啟動隨 Visual Studio 2019 的社區安裝的開發人員命令提示字元。This command launches the Developer Command Prompt that's installed with Visual Studio 2019 Community. 根據您的 Visual Studio 版本和安裝位置變更這個值。Change this value according to your Visual Studio version, edition, and installation location.

  8. 在 [初始目錄] 欄位中,指定要在其中啟動命令提示字元的目錄。In the Initial directory field, specify the directory in which the command prompt will start. 選取欄位旁的箭號,以選擇 [專案目錄] 之類的值。Choose a value such as Project Directory by selecting the arrow next to the field.

  9. 選擇 [ 確定 ] 按鈕。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