DESKTOP

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

1/11/2011 4:14:52 PM

Visual Studio uses logical containers — projects and solutions — for grouping all the code and resources associated with an application.

  • Solutions contain all the projects necessary to build an application.

  • Projects include all the source code and support files necessary to create the application.

For example, a solution may contain one project each for the following:

  • Windows Forms

  • Data-access code

  • Database code

  • Testing code

  • The installer

The process of converting all the code found in a set of projects to an application is building or creating a build. Builds have settings that define where the output files are located and whether debug information is included. A group of settings is a build configuration. Visual Studio solutions and projects include two default build configurations:

  • Debug: Code compiles with information for debugging and no optimization. The nature of the build is to enable you to test your code.

  • Release: Code compiles with optimizations and no debugging information. The release configuration is intended for production deployment.

Builds can target a specific hardware platform, such as the 32-bit (x86) or 64-bit (x64) architectures. The Debug and Release build configurations provided by Visual Studio target the x86 architecture.

1. The anatomy of a build

Building software takes a set of inputs and creates a set of outputs. The inputs include the following:

  • Source-code files

  • Resource files

  • Configuration files

  • Local database files

The build process takes these files and converts them to a set of outputs that include

  • Tokenized files, such as application executables and dynamic link libraries (DLLs). Binary files are assemblies.

  • Debugging information, which is stored in a program database (PDB) file.

  • Feedback messages, such as compiler warnings and errors.

The build process uses a compiler to convert your human-readable input files into machine-readable binary files. Each programming language uses its own compiler.

You use the outputs from a build to accomplish the following:

  • Test an application you're developing.

  • Deploy an application to a test or production environment.

  • Determine whether you can check in your source code to form part of your source-code repository.

    Inputs to the build process — the source code — are checked in (established as source code) after you have a successful build.

Figure 1 shows the build process. Note that the outputs are deployed, but usually they're not checked into source code control.

Figure 1. The build process creates a set of deployable outputs.

2. Using the Build menu

Visual Studio provides a Build menu from which you can launch different build commands for your solution or project. The options on the Build menu are

  • Build Solution: Compiles any source code that hasn't yet been compiled. The Build command doesn't delete any existing output files. Instead, the Build command performs an incremental build of any files not yet compiled.

  • Rebuild Solution: Deletes, or cleans, any existing output files and compiles all source code into binary files.

  • Clean Solution: Deletes all the output files generated by previous builds.

  • Publish: Calls the Publishing Wizard to build and deploy the solution.

  • Batch Build: Compiles multiple build configurations as a batch.

Deployable projects, such as SQL Server Reporting Projects, display the Deploy command on the Build menu. If you have the Web Deployment Project Add-In installed, you also have the option Add Web Deployment Project on the Build menu.

You execute build commands against solutions or individual projects. Here are some scenarios for how you can use the Build menu:

  • Build projects individually when a solution has many projects. Compiling large solutions and projects is time consuming. For that reason, you may choose to build individual projects as you need them rather than building the entire solution. Using the Build command to incrementally compile source files can also save time.

  • Build each project in a solution individually when a dependent project generates compile errors. When a solution has many projects that are dependent upon one another, an error in one project cascades to the dependent projects, which makes finding the original error difficult. Instead of plowing through a long list of errors and warnings, compile each project individually and deal with any errors you find.

  • Build an entire solution. If your solution builds lightning-fast, you can use either the Build or the Rebuild Solution command.

    Use the Rebuild Solution option (rather than Build) if you're getting strange errors that you don't think you should be getting. Using Rebuild Solution wipes out all the previous build's outputs.

  • Build individual projects as changes are made to them. When you have large projects and solutions, building is faster than rebuilding the entire solution.

Using the Start command from the Debug menu calls the Build command and executes your application. During development, many developers press the F5 key with the expectation that their code is going to build and execute.

Only after they see that long list of compiler errors do they start using the Build menu.

The commands on the Build menu correspond to targets files used by the Microsoft Build Engine (MSBuild).

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
    How To Basics Installing Linux
    How To Basics Virtualization
    Nero 12 Platinum Multimedia Software
    Ten Popular Open Source Media Players
    Top Mind Mapping Tools For Android
    Ultra-portable Devices Eat Into The Legacy PC Market (Part 3)
    Ultra-portable Devices Eat Into The Legacy PC Market (Part 2)
    Ultra-portable Devices Eat Into The Legacy PC Market (Part 1)
    JBL Flip Portable Wireless Loudspeaker
    AOC E2460phu LED LCD 24” Monitor
    Most View
    Windows Server 2008 : Designing Organizational Unit and Group Structure - Understanding Group Design
    The long road to thin and light computing (part 2)
    Managing Local Logon
    Windows Server 2003 : Hardening IPSecurity Policies
    iPhone Application Development : Building a Multi-View Tab Bar Application (part 4) - Implementing the Summary View
    Apple iPhone 5 - Fails To Return To The Top (Part 2)
    Building Android Apps: Create an Android Virtual Device
    Three Quick Ways To View Notification Center
    Buying Guide: Gaming PCs For Hardcore Gamers' Dreams (Part 1) - Arbico Elite 5357 OCX
    Is Small Beautiful, Or Is Bigger Better For Ios Devices?
    BenQ GW2250 21.5 Widescreen LCD Monitor
    The Best Apps and Gear of 2012 (Part 12)
    Windows Server 2008 : Installing and Configuring FTP Services (part 1) - Installing the FTP Server & Creating a Secure FTP 7.5 Site Using SSL
    Is computer only a big smartphone?
    Make The Switch (Part 2)
    Ministry Of Soundbars : Orbitsound T9, LG NB3520A, Bose CineMate 1SR, Bar, Samsung HT-E8200
    Lenovo Thinkpad Carbon Touch Ultrabook Review (Part 1)
    Windows Sever 2003 : Troubleshooting Name Resolution
    Windows 7 : Configuring Network Connectivity - Configuring DirectAccess
    Windows Server 2008 Server Core : Working with Scripts - Impersonating a User with the RunAs Utility, Changing the Environment