5. Using Configuration Manager
You use Configuration Manager
to create new build configurations and manage existing configurations
for solutions and projects. You use Project Designer to associate a
project's properties with its build configuration.
To create a new build configuration by using Configuration Manager, follow these steps:
Choose Configuration Manager from the Build drop-down list.
Configuration Manager appears, displaying the configuration settings for the configuration and platform selected at the top.
Choose New from the Active solution configuration drop-down list.
The New Solution Configuration window appears.
Type Staging in the Name field.
Choose Debug from the Copy Settings From drop-down list.
Leave the Create New Project Configurations check box selected.
Click OK.
The new configuration appears in Configuration Manager, as shown in Figure 6.
A solution's build configuration is composed of two main elements:
For each project in the solution, you select a project configuration and a platform, as shown in Figure 6.
You create new project configurations and hardware platforms, if
necessary. You include the project in the build by placing a check in
the Build column. You use Project Designer to set the properties for
each project configuration. Figure 7
shows an example of selecting a project configuration for a solution
configuration, which you can get to by going to the project properties
under the Project menu.
Visual Studio writes the
build configurations you create in Configuration Manager to the
appropriate solution or project file. When you build your solution or
project, MSBuild uses the solution or project files as a script. For
example, the following line is added to the solution file for the
staging build configuration:
Staging|Any CPU = Staging|Any CPU
Open your solution file or project file in any text editor to view the changes made by Configuration Manager.
If you have a
specific hardware platform in mind, you can use Configuration Manager to
specify that a build should target that platform. For example, to
create a new Debug solution configuration that targets the x64 platform,
follow these steps:
Open Configuration Manager.
Choose Debug from the Active Solution Configuration drop-down list.
Choose New from the Active Solution Platform drop-down list.
The New Solution Platform window appears.
Select x64 as the new hardware platform.
Click OK.
A new Debug solution configuration for the x64 platform is created.
If you're using the MSBuild Toolkit, you can select a version of the .NET Framework to target using the Platform.
6. Setting project configurations
Visual Studio solutions and projects have many settings — properties — that define the solution or project. These properties define attributes, such as
You access the
properties for a solution or project by choosing Properties from the
solution's or project's shortcut menu. The two views for properties are
Project Designer:
Displays properties for a project in Document Explorer. All Visual
Studio projects use Project Designer to manage their properties.
Property Pages: Displays properties in a dialog box. Solutions and ASP.NET Web sites use the Property Pages window to manage their properties.
ASP.NET Web sites don't use
projects, so they don't use Project Designer. Microsoft has a project
type (Web Application Projects) that allows you to have ASP.NET
projects.
6.1. Using Project Designer
Visual Studio 2010
includes a new feature — Project Designer — that you use to access your
project's configuration settings in a single designer.
To open Project Designer, follow these steps:
Right-click your project in Solution Explorer.
A shortcut menu appears.
Choose Properties.
Project
Designer appears in Document Explorer, showing a set of tabs along the
left that group common properties. To access a set of properties, click
its tab. Figure 8 shows the Project Designer for a class library project type.
You can also open Project Designer from the Project menu.
Some tabs in Project
Designer feature properties that you can configure to match your build
configuration type. For example, you can set build properties for a
Debug build. To set the build properties for a C# project type, follow
these steps:
Click the Build tab.
The project's build properties appear.
Choose a build configuration from the Configuration drop-down list.
The
properties for the selected build configuration appear. If you want to
manage properties for all your build configurations, you can choose All
Configurations.
Choose a build platform from the Platform drop-down list.
Set properties in Project Designer.
The
properties that you choose depend largely on whether you intend to
debug or release the output. The properties for Visual Basic projects
are slightly different because the compilers are different.
You won't find an OK or a Save button for Project Designer. The properties are saved immediately.
The Project Designer for
Visual Basic project types has a Compile tab instead of a Build tab. You
can access build properties from the Compile tab.
You can set unique
build configuration settings for properties in the Build and Debug tabs
in C# project types. For Visual Basic project types, you set these items
on the Build and Compile tabs.
6.2. Using property pages
Solutions and ASP.NET Web
sites use the Property Pages dialog box to manage properties. Here's how
to use a solution's property pages to set project dependencies:
Right-click the solution in Solution Explorer.
A shortcut menu appears.
Expand Common Properties.
A list of properties appears.
Click Project Dependencies.
Choose a project from the Project drop-down list (see Figure 9).
Your project must have more than one project to set project dependencies.
Check the project dependencies and click OK.
To verify that your projects build in the correct order, choose Projects=>Project Build Order.