Compartir a través de


Devenv command-line switches

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Devenv lets you set various options for the IDE, build projects, debug projects, and deploy projects from the command line. Use these switches to run the IDE from a script or a .bat file (such as a nightly build script), or to start the IDE in a particular configuration.

Note

For build-related tasks, it's recommended that you use MSBuild instead of devenv. For more information, see MSBuild command-line reference.

For information about switches that are related to VSPackage development, also see Devenv command-line switches for VSPackage development.

Devenv switch syntax

Commands that begin with devenv are handled by the devenv.com utility, which delivers output through standard system streams, such as stdout and stderr. The utility determines the appropriate I/O redirection when it captures output, for example to a .txt file.

Alternatively, commands that begin with devenv.exe can use the same switches, but the devenv.com utility is bypassed. Using devenv.exe directly prevents output from appearing on the console.

The syntax rules for devenv switches resemble the rules for other DOS command-line utilities. The following syntax rules apply to all devenv switches and their arguments:

  • Commands begin with devenv.

  • Switches aren't case-sensitive.

  • You can specify a switch by using a hyphen ("-") or a forward slash ("/").

  • When specifying a solution or project, the first argument is the name of the solution file or project file, including file path.

  • If the first argument is a file that's not a solution or project, that file opens in the appropriate editor, in a new instance of the IDE.

  • When you supply a project file name instead of a solution file name, a devenv command searches the parent folder of the project file for a solution file that has the same name. For example, the command devenv myproject1.vbproj /build searches the parent folder for a solution file that's named myproject1.sln.

    Note

    One and only one solution file that references this project should be located in its parent folder. If the parent folder contains no solution file that references this project, or if the parent folder contains two or more solution files that reference it, then a temporary solution file is created.

  • When file paths and file names include spaces, you must enclose them in quotation marks (""). For example, "c:\project a\".

  • Insert one space character between switches and arguments on the same line. For example, the command devenv /log output.txt opens the IDE and outputs all log information for that session to output.txt.

  • You can't use pattern-matching syntax in devenv commands.

Devenv switches

The following command-line switches display the IDE and do the described task.

Command line switch Description
/Command Starts the IDE and executes the specified command.

devenv /command "nav https://docs.microsoft.com/"
/DebugExe Loads a C++ executable under the control of the debugger. This switch isn't available for Visual Basic or C# executables. For more information, see Automatically start a process in the debugger.

devenv /debugexe mysln.exe
/Diff Compares two files. Takes four parameters: SourceFile, TargetFile, SourceDisplayName (optional), and TargetDisplayName (optional).

devenv /diff File1 File2 Alias1 Alias2
/DoNotLoadProjects Opens the specified solution without loading any projects.

devenv /donotloadprojects mysln.sln
/Edit Opens the specified files in a running instance of this application. If there are no running instances, it starts a new instance with a simplified window layout.

devenv /edit File1 File2
/LCID or /L Sets the default language for the IDE. If the specified language isn't included in your installation of Visual Studio, this setting is ignored.

devenv /l 1033
/Log Starts Visual Studio and logs all activity to the log file.

devenv /log mylogfile.xml
/NoSplash Opens the IDE without showing the splash screen.

devenv /nosplash File1 File2
/ResetSettings Restores Visual Studio default settings. Optionally resets the settings to the specified .vssettings file.

devenv /resetsettings mysettings.vssettings
/Run or /R Compiles and runs the specified solution.

devenv /run mysln.sln
/RunExit Compiles and runs the specified solution, minimizes the IDE when the solution is run, and closes the IDE after the solution has finished running.

devenv /runexit mysln.sln
/SafeMode Starts Visual Studio in safe mode. This switch loads only the default environment, the default services, and the shipped versions of third-party packages.

This switch takes no arguments.
/TfsLink Opens Team Explorer and launches a viewer for the provided artifact URI if one is registered.
/UseEnv Causes the IDE to use PATH, INCLUDE, LIBPATH, and LIB environment variables for C++ compilation. This switch is installed with the Desktop development with C++ workload. For more information, see Setting the Path and Environment Variables for Command-Line Builds.

The following command-line switches don't display the IDE.

Command line switch Description
/? Displays help for devenv switches in the Command Prompt window.

This switch takes no arguments.
/Build Builds the specified solution or project according to the configuration of the specified solution.

devenv mysln.sln /build
/Clean Deletes any files created by the build command, without affecting source files.

devenv mysln.sln /clean
/Deploy Builds the solution, along with files necessary for deployment, according to the solution's configuration.

devenv mysln.sln /deploy
/Out Lets you specify a file to receive errors when you build.

devenv mysln.sln /build Debug /out log.txt
/Project The project to build, clean, or deploy. You can use this switch only if you've also supplied the /Build, /Rebuild, /Clean, or /Deploy switch.

devenv mysln.sln /build Debug /project proj1
/ProjectConfig Specifies the project configuration to build or deploy. You can use this switch only if you've also supplied the /Project switch.

devenv mysln.sln /build Release /project proj1 /projectconfig Release
/Rebuild Cleans and then builds the specified solution or project according to the configuration of the specified solution.

devenv mysln.sln /rebuild
/Upgrade Upgrades the specified solution file and all its project files, or the specified project file, to the current Visual Studio formats for these files.

devenv mysln.sln /upgrade

See also