Compartir a través de


Devenv Command Line Switches

Note

This article applies to Visual Studio 2015. 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 integrated development environment (IDE), and also build, debug, and deploy projects, from the command line. Use these switches to run the IDE from a script or a .bat file, for example, a nightly build script, or to start the IDE in a particular configuration.

Note

For build-related tasks, it is now recommended that you use MSBuild instead of devenv. For more information, see Command-Line Reference.

Note

You must run devenv as an adminstrator in order to use the /Setup (devenv.exe) and /InstallVSTemplates (devenv.exe) switches.

Devenv Switch Syntax

By default, devenv commands pass switches to the devenv.com utility.

The devenv.com utility provides for the delivery of output through standard system streams, such as stdout and stderr, and determines the appropriate I/O redirection when it captures output, for example, to a .txt file. Commands that begin instead with devenv.exe can use the same switches, but will send them to the devenv.exe program, bypassing the devenv.com utility.

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

  • Commands begin with devenv.

  • Switches are not case-sensitive.

  • 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 is not a solution or project, that file will open 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 will search the parent folder of the project file for a solution file that has the same name. For example, the command devenv /build myproject1.vbproj will search the parent folder for a solution file that is 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 will be created that is named for this project and references it.

  • When file paths and file names include spaces, you must enclose them in double 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 cannot use pattern-matching syntax in devenv commands.

Devenv Switches

Use the following command-line switches to display the IDE and perform the described task.

Command line switch Description
/Command (devenv.exe) Starts the IDE and executes the specified command.
/DebugExe (devenv.exe) Loads a Visual C++ executable under the control of the debugger. This switch is not available for Visual Basic or Visual C# executables. For more information, see Automatically start a process in the debugger.
/LCID (devenv.exe) or /l Sets the default language for the IDE. If the specified language is not included in your installation of Visual Studio, this setting will be ignored.
/Log (devenv.exe) Starts Visual Studio and logs all activity to the log file.
/Run (devenv.exe) or /r Compiles and runs the specified solution.
/Runexit (devenv.exe) Compiles and runs the specified solution, minimizes the IDE when the solution is run, and closes the IDE after the solution has finished running.
/UseEnv (devenv.exe) Causes the IDE to use PATH, INCLUDE, and LIB environment variables for Visual C++ compilation instead of the settings specified in the VC++ Directories section of Projects options in the Options dialog box. For more information, see Setting the Path and Environment Variables for Command-Line Builds
/Edit (devenv.exe) Opens the specified files in a running instance of this application. If there are no running instances, it will start a new instance with a simplified window layout.
/ResetAddin (devenv.exe) Starts an instance of the Visual Studio IDE without loading the specified Add-in.
/SafeMode (devenv.exe) Starts Visual Studio in safe mode, and loads only the default environment and services, and shipped versions of third-party packages.
/ResetSkipPkgs (devenv.exe) Clears all SkipLoading tags that have been added to VSPackages by users who want to avoid loading problem VSPackages.
/Setup (devenv.exe) Forces Visual Studio to merge resource metadata that describes menus, toolbars, and command groups, from all VSPackages available.

Use the following command line switches to perform the described task. These command-line switches do not display the IDE.

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

Devenv /?
/Build (devenv.exe) Builds the specified solution or project according to the configuration of the specified solution.

Devenv myproj.csproj /build
/Clean (devenv.exe) Deletes any files created by the build command, without affecting source files.

Devenv myproj.csproj /clean
/Deploy (devenv.exe) Builds the solution, along with files necessary for deployment, according to the solutions configuration.

Devenv myproj.csproj /deploy
/Diff Compares two files. Takes four parameters:SourceFile, TargetFile, SourceDisplayName(optional),TargetDisplayName(optional).
/InstallVSTemplates (devenv.exe) Registers project or item templates that are located in <VisualStudioInstallDir>\Common7\IDE\ProjectTemplates or <VisualStudioInstallDir>\Common7\IDE\ItemTemplates so that they can be accessed through the New Project and Add New Item dialog boxes.

Devenv /InstallVSTemplates
/Out (devenv.exe) Lets you specify a file to receive errors when you build.

Devenv myproj.csproj /build /out log.txt
/Project (devenv.exe) The project to build, clean, or deploy. You can use this switch only if you have also supplied the /build, /rebuild, /clean, or /deploy switch.
/ProjectConfig (devenv.exe) Specifies the project configuration to build or deploy. You can use this switch only if you have also supplied the /project switch.
/Rebuild (devenv.exe) Cleans and then builds the specified solution or project according to the configuration of the specified solution.
/ResetSettings (devenv.exe) Restores Visual Studio default settings. Optionally resets the settings to the specified .vssettings file.
/Updateconfiguration (devenv.exe) Notifies Visual Studio to merge the Visual Studio packages on the system and check the MEF cache for any changes.
/Upgrade (devenv.exe) Upgrades the specified solution file and all its project files, or the specified project file, to the current Visual Studio formats for these files.

See Also

General, Environment, Options Dialog Box