#494 – Selecting a Solution-Level Build Configuration and Platform

Visual Studio 2010 supports both solution-level and project-level build configurations.  The project-level configurations specify sets of build-related properties.  The solution-level configuration specifies which projects to build for a particular configuration, as well as the individual project-level configurations to use.

There are also both solution-level and project-level platform choices.

You can see your current solution-level build configuration and platform in the main Visual Studio 2010 toolbar.

In the example below, the current build configuration is Debug and the current platform is Any CPU.

To build your project under a different build configuration or platform, just make a new choice in one or both of these combo boxes.

In the example below, we’ve chosen to do a Release build for the x86 platform.

 

#493 – Project Properties Are Specific to Build Configuration and Platform

Many tabs in the project properties window include two combo boxes at the top of the tab, allowing selection of Configuration and Platform.

This window allows you to specify a set of property values for each combination of Configuration and Platform.  For example, you might have Debug and Release choices for Configuration, as well as x86 and x64 choices for Platform.  You could then specify a different value for Output path for each combination of Configuration and Platform, so that you could save four sets of binaries.

  • Debug|x86 – \bin\x86\Debug
  • Debug|x64 – \bin\x64\Debug
  • Release|x86 – \bin\x86\Release
  • Release|x64 – \bin\x64\Release

#492 – Define Your Own Conditional Compilation Symbol

You can define your own conditional compilation symbols for specific build configurations and then use the #if directive to check these symbols and conditionally compile code, depending on whether the symbol is defined or not.

For example, suppose you want to execute some debugging code only for Debug builds that are targeting the x86 platform.  You can define a new DEBUG86 symbol that is present only when the build configuration is Debug and the platform is x86.

You can then use the #if directive to compile some code only when this symbol is defined.

#if DEBUG86
            Console.WriteLine("This is a 32-bit Debug build..");
#endif