DESKTOP

Visual Studio 2010 : Understanding Solutions and Projects (part 2)

1/11/2011 4:16:25 PM

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:

  • Build configuration

  • Compiler and switches used

  • Output from the compiler

  • Build status

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 Studio.

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.

Other  
  •  Becoming an Excel Programmer : Macros and Security
  •  Becoming an Excel Programmer : Where's My Code?
  •  Becoming an Excel Programmer : View Results
  •  Becoming an Excel Programmer : Start and Stop
  •  Windows Server 2008 : Configuring and Monitoring Terminal Service Resources
  •  Visual Studio 2010 : Understanding Debugging
  •  Visual Studio 2010 : Structured Exception Handling to the Rescue
  •  Implement an Observer (aka Subscriber) Pattern
  •  Use a Stopwatch to Profile Your Code
  •  Combine Multiple Events into a Single Event
  •  Internet Security and Acceleration Server 2004 : Additional Configuration Tasks
  •  Windows Server AppFabric
  •  Cloud Application Architectures : Privacy Design
  •  Cloud Application Architectures : Machine Image Design
  •  Windows Azure : Using the Storage Client Library
  •  Windows Azure : Using the Blob Storage API
  •  Windows Azure : Blobs - Usage Considerations
  •  Windows Azure : Understanding the Blob Service
  •  Design and Deploy High Availability for Exchange 2007 : Design Edge Transport and Unified Messaging High Availability
  •  Design and Deploy High Availability for Exchange 2007 : Design Hub Transport High Availability
  •  
    Top 10
    HP Envy 23 TouchSmart All-in-One
    Sony VAIO Tap 20 - Sony's 20in Tablet Is An All-In-One PC
    Toshiba All In One LX830 Computers
    10 Things You Need To Know About Flash
    Desktop Organisation Tools (Part 3) : RocketDock, Dexpot
    Desktop Organisation Tools (Part 2) : Tiles
    Desktop Organisation Tools (Part 1)
    Explore The Limits Of Your Android Device
    Ten Cool Custom Android ROMs (Part 2)
    Ten Cool Custom Android ROMs (Part 1)
    Most View
    How To Buy…Speakers (Part 1)
    DrawScribe : Simplify The Process
    SSD Supertest – December 2012 (Part 4) : OCZ Vertex 4 256GB, Plextor M5 Pro 128GB
    Digital SLRs Market Overview
    Active Directory Lightweight Directory Service (LDS)
    Animations in Silverlight
    Exploring the T-SQL Enhancements in SQL Server 2005 : Common Table Expressions
    Windows Server 2003 : Active Directory Objects and Concepts
    SQL Server 2008 : Transact-SQL Programming - TRY...CATCH Logic for Error Handling
    Things That Create The Success Of Smartwatch (Part 1)
    MySQL for Python : Creating Users and Granting Access - GRANT access in MySQL
    Apps Of The Month – November 2012 : Google Play Movies & TV, NavFree for iOS
    OS X Mountain Lion: What’s New - The System (Part 6)
    Experience Sony NEX-3N (Part 2)
    Building and Deploying Applications for Windows Azure : Activating the Storage Account Account
    Sand, Sea And Samsung (Part 1)
    Iomega EZ Media & Backup Center - Save You Some Money
    IIS 7.0 : Managing Virtual Directories
    Laptop HD Pavillion DM1 - 3200SA - The Thinnest Ultraportables
    Galaxy S4 vs iPhone 5 - The One Launched Later Is Not Necessary Better (Part 2)