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 10 中In 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.1 中In 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 8 中In 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 7 中In 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.

如果安装了其他 SDK,例如 Windows 10 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(该路径根据你的 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