2006-02-26
| Table of Contents: |
| Rate This Article: | Add This Article To: |
( Page 2 of 3 )
Loading Projects with a Shortcut
You can load any project by typing DevEnv, followed by the solution filename, project filename, or single filename, then pressing Enter. The IDE automatically loads everything required to start the project.
Of course, you perform this task quite easily with the IDE. What makes the command line special is that you don't have to search for the project on the hard drive. You create a shortcut that contains everything needed to load the project. Placing these shortcuts on the Desktop makes them fast loading and quite accessible.
I usually place my shortcuts in a project folder. That way, no matter where a project is physically located, I can access it easily by double clicking the entry in the project folder.
To create your own shortcut, begin by right-clicking an open area in the folder where the shortcut will appear. Choose New | Shortcut from the context menu. The "Create Shortcut" wizard will appear. You must provide three pieces of information in the Type the Location of the Item field, as shown here in the sample.
%comspec% /c "F:\Program Files\Microsoft Visual Studio 8\Common7\IDE\DevEnv.EXE" DateTimeVisualizer.sln
The first entry, %comspec%, creates a command processor. The /c command line switch tells the command processor to execute a command and exit. The second entry is the command to execute, which is the development environment. Notice that you must place this entry in quotes because it contains spaces. The example shows my configuration; make sure you change it to match your setup. The third entry is the name of the solution, project, or file that you want to open. You could also add any of the command line switches provided in this article to the command line.
Once you enter the command line, click Next, and follow the remaining wizard instructions. After you create the shortcut, you must make one additional change. Right click the new shortcut and choose Properties from the context menu. Type the full path to the solution in the Start In field on the Shortcut tab for the shortcut's properties dialog box. Now, whenever you double click the shortcut, the project will start.
Performing the Automated Compile
Depending on the size of your project, you might want to wait to compile it until everyone has gone home for the day. Of course, you might have multiple modules and a complex work environment. Unless you want to stay at work all night getting compilation tasks completed, you should consider another course of action.
By combining command line switches with the Task Scheduler, you can create nightly jobs for the development environment while you're at work, during daylight hours. Using this approach, the Task Scheduler ensures that the development environment completes the work while you're at home.
Microsoft obviously expects developers to perform many different kinds of application build options because they provide a number of command line switches for the task. You can even perform deployments after hours using the command line switches that the DevEnv command provides. Here's a list of the automatic compilation related command line switches.
- /Build ConfigurationName: Builds the application according to the configuration name you provide. For example, you can use this command line switch to create either a debug or a release build. The development environment doesn't rebuild any existing source code that hasn't changed when you use this option. You must provide a solution name as input with this command line switch.
- /Rebuild ConfigurationName: Cleans up any existing executables and object files first, and then builds the application according to the configuration name you provide. As with the
/Buildcommand line switch, you can create any named configuration and you must provide a solution name as part of the input for this command line switch. - /Project ProjectName: Defines the name of a project to use during the compilation process. Instead of compiling an entire solution, the development environment only compiles a single project within that solution. You can't use this command line switch alone; it must appear with the
/build, /rebuild, /deploy, or/cleancommand line switches. You must provide a solution name as input with this command line switch. - /ProjectConfig ConfigurationFilename: Specifies the name of a file that contains configuration information. You can use this command line switch to add a new build configuration or overwrite an existing configuration of the same name.
- /Clean ConfigurationName: Cleans up the object and executable files for an application without compiling it using the specified configuration file settings. This feature is handy when you want to send a project to someone without burdening them with all of the object and executable files as well. The source code is significantly smaller than the resulting executables. You must provide a solution name as input with this command line switch.
- /Deploy ConfigurationName: Deploys an application after the development environment builds or rebuilds it, according to the configuration you provide. This feature works very well for team development, where you want a group of testers to work with the current build (looking for bugs and usability problems) while your development team continues work on the application code. The source code is significantly smaller than the resulting executables. You must provide a solution name as input with this command line switch.
- /Upgrade: Upgrades a project or solution to the latest version of Visual Studio. The development environment creates a backup of the old project or solution for you in a backup directory. You can use this backup to revert to the previous version of Visual Studio when desired.
- /Out Filename: Specifies the name of an error file to receive all errors. This command line switch is a requirement when you perform after hours or unassisted builds. Otherwise, you can't be sure of seeing a complete error list.
- /Log Filename: Specifies the name of a log file that receives all development environment activity information. You can use this feature to track IDE usage, check for the execution of macros, or verify that the IDE is working in a specific manner while performing tasks automatically. Unlike the
/Outswitch, this command line switch doesn't focus on build errors; it provides you with detailed usage information that can become quite large over time. - /NoLogo: Performs the build without displaying the normal logo and copyright information. This command line switch is especially useful when you use automation to handle build errors.
Executing Commands Automatically
Perhaps the most powerful command line switch is /Command. You can follow this command line switch any command that you can execute within the IDE. For example, to open the IDE with the project dialog box open, you could use
DevEnv /Command File.OpenProject
Whenever you start the IDE using a command, the IDE doesn't display the Start page. Unless you actually use the Start page (and many people do), this shouldn't be a hindrance. To use a command, you must provide the correct alias for the command. In this case, File.OpenProject is an alias for the File | Open | Project menu sequence. Find a list of aliases that the IDE recognizes here.
You can also use this feature to execute macros. Consequently, you can create a macro to perform any level of processing you want and execute it from the command line. When combined with Task Scheduler, you can perform a wealth of tasks while you're sleeping. Here's an example of a macro execution from the command line.
DevEnv /Command "Macros.MyMacros.DoTasksModule.PerformProcessing"
![]() |
|


