
Launch Visual Studio from the Command Prompt #78
Chapter 10, Work with Visual Studio Tools
|
327
HACK
Execute a Command
Using the command switch, you can launch Visual Studio and automati-
cally call a Visual Studio command. All you need to do is specify the switch
/command and then follow it with the name of the command that you want to
execute. These are the same commands covered in “Master the Command
Window”
[Hack #46]. In this example, I will call the File.OpenSolution com-
mand—I almost always open Visual Studio with the intent of opening a
solution, so this saves a couple of mouse clicks:
C:\> devenv /command File.OpenSolution
When you run this command, Visual Studio will open, and the New Solu-
tion dialog will open. You could also use
/command to execute a macro you
have written to perform more complex actions.
Run a Solution
You can automatically run a solution from the command line using the /run
switch. The following is an example of running a solution from the com-
mand line:
C:\> devenv /run HacksWinSample.sln
When this command is run, the IDE will open and automatically jump into
debug mode loading your application. You can also use the
/runexit switch,
which will launch your applications and minimize the IDE. When you close
your application, the IDE will be closed as well.
Building Projects and Solutions
You can build your projects or solutions using command-line switches. This
can be a great ...