3. Selecting the active build and platform
When you build a solution or
a project, you select a named build configuration you want to build,
such as Debug or Release. Each build configuration has specific
properties that determine how the project is built. Visual Studio 2010
automatically creates the Debug and Release build configurations for
each project and solution you create.
The build process creates
code for a specific hardware platform (such as the Intel x86 or x64
architectures). You pick a hardware platform when you build your
solution or project.
To set a build
configuration and a hardware platform for a build, use the Solution
Configuration and Solution Platform drop-down lists on the Standard
toolbar, as shown in Figure 2.
Figure 2. Select the build type.
4. Dealing with compiler errors and output
The major function of the
build process is to compile your source code into binary files. The
build process provides output that shows the list of commands executed,
along with any feedback from those commands. If the compiler can't
compile your code, error messages appear in the Error List window.
If you execute your build
by using the Start command from the Debug menu, a dialog box warns you
that the build was unsuccessful. If you use the Build menu, the Error
List window appears. Figure 1-3 shows an error message that cropped up when trying to use a variable that hadn't yet been declared.
Each programming language uses its own compiler. The message displayed in Figure 3 is from the C# compiler. The Visual Basic compiler displays the following message for the same error:
Name 'myVariable' is not declared.
Figure 3. Error and warning messages from the compiler appear here.
Among other things, you can use the Errors window to
Go to the source code where the error occurred. When you double-click an error, Visual Studio opens the source-code file and positions the cursor where the error occurred.
Get help on an error. Right-click an error and choose Show Error Help from the shortcut menu.
Hover your mouse pointer over an error in source code to display the error in a ToolTip, as shown in Figure 4.
Use the Output window to view the commands executed by the build process. The Output window displays the following information:
Messages appear for each project compiled in the build. Figure 5 shows a successful build for a single project, using the Debug build configuration.
Figure 4. The ToolTip shows the error.
The long line that appears in Figure 5
between the first and last lines is a single command that executes the
compiler. To create this command, the Build command pulls all the
project settings, references, and properties that you set in Visual
Figure 5. The Output window displays the compiler command used to build your project.
You can copy and paste the
compiler command from the Output window to reuse on the command line or
in a batch file. Batch files are a good way to automate builds. You'll
probably need to qualify the path names to your project's resources. To
open a Visual Studio command prompt, choose Start=>All Programs=>Microsoft Visual Studio 2010=>Visual Studio Tools=>Visual Studio Command Prompt (2010).
To specify whether a file should be compiled with a project, use the Properties window to set the file's BuildAction property.