Visual Studio Command Line Switches (
Page 1 of 2 )
Visual Studio includes several command-line switches that you can use to have more control over how VS operates.
Introduction
A lot of people might not realize that Visual Studio allows for many command-line parameters to control how it runs. Visual Studio runs by default, in the 2008 version, from <Program Files>\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe. In this article, I look at some of the common commands, and what scenarios they might be useful in.
ADVERTISEMENT
General Switches
/?
If you run DevEnv.exe directly from the command line with a help switch (/?), you will see numerous commands for working with and configuring the Visual Studio environment. Note the help switch is not recursive to get switch-specific help.
/LCID
If you would like to change the language used by Visual Studio for displaying text, currency, and other values, you can use the /LCID switch, along with the language ID of the supported language you wish to use.
The syntax for this switch is:
devenv /LCID <language id>
The currently supported languages are:
Language
LCID
Chinese (Simplified)
2052
Chinese (Traditional)
1028
English
1033
French
1036
German
1031
Italian
1040
Japanese
1041
Korean
1042
Spanish
3082
Working with Projects and Solutions
One common use of the command line capabilities of DevEnv is working with building, cleaning, and deploying projects and solutions in an automated manner.
/Build
You are certainly familiar with building projects and solutions from within the Visual Studio environment, but you can also use the DevEnv command line tool using the Build switch.
To build a solution, you can simple pass in the path to the solution file and optionally a configuration, such as debug or release. Projects are compiled by using the Project switch, and you can build one project at a time, also optionally specifying the configuration to use.
This switch functions in a similar manner to the Build switch, but it only removes files from the obj and bin directories. As with the Build switch, to clean a solution, you can simply pass in the path to the solution file and optionally a configuration, such as debug or release. Projects can be cleaned individually by using the Project switch and you can clean one project at a time, also optionally specifying the configuration to use.
The Rebuild switch is identical to the Build switch, except that it first cleans and then completely builds the project or solution.
/Deploy
Deployment projects can be built, and if built successfully, are deployed by using the devenv Deploy switch. This is a great way to automate deployments without having to open the IDE.
/Edit
The Edit switch allows you to open one or more files in Visual Studio. If an instance of Visual Studio is already running, it will be used to open the files. Otherwise, a new instance will be created.
The syntax to use is:
devenv /edit [file1 [file2 [fileN]]]
/Upgrade
To upgrade a solution to Visual Studio 2008 from prior versions, you can use the command line. Unlike the graphical upgrade however, a backup is automatically created in a folder named Backup, and any projects or solutions under source control must already be checked out. Visual Studio will not be opened as a result of running this command.
The syntax to use is:
devenv {solutionfile | projectfile} /upgrade
/Out
Sometimes when running an automated build, errors occur and a method to diagnose them is needed. The Out switch writes build and run errors to a specified log file.
The syntax to use is:
devenv /out [log file name]
/Run
The /run switch enables you to compile and run the solution from the command line and can be useful in testing scenarios.
The syntax to use is:
devenv /run {solutionfile | projectfile}
/RunExit
The /runexit switch is identical to the /run switch with the addition of closing Visual Studio when the run completes.