.NET 部署04关于生成配置(Build Configurations)

原文地址:http://msdn.microsoft.com/en-us/library/kkz9kefa(v=VS.80).aspx

 

在介绍 Web Deployment 项目时,提到生成配置问题,本文在此介绍。由于本文主要是讲如何在VS中进行设置,所以暂时不翻译。

 

生成(Build)配置

Build configurations provide a way to store multiple versions of solution and project properties. The active configuration can be quickly accessed and changed, allowing you to easily build multiple configurations of the same project.

By default, and projects created with Visual Studio include Debug and Release configurations. Debug configurations are automatically configured for debugging an application, and Release configurations are configured for the final release of an application. For more information, see How to: Set Debug and Release Configurations. You can also create and edit your own custom solution and project configurations to meet the needs of your application. For more information, see How to: Create and Edit Configurations.

Two levels of build configurations can be defined in Visual Studio: solution configurations and project configurations.

 

解决方案配置

A solution configuration specifies how the projects in a solution are to be built and (if enabled) deployed. To define a new solution configuration, open the Configuration Manager Dialog Box and select New from the Active solution configuration list.

Each entry in a solution configuration includes a project name, a configuration setting, a platform setting, a build setting, and (if enabled) a deploy setting. The combination of solution configuration and solution platform settings chosen determines the project configuration that will be used. For more information on solution platforms, see Build Platforms.

You can create any number of solution configurations, each with a unique name. The Visual Studio integrated development environment (IDE) automatically assigns solution configurations whenever you:

  • Add a project platform with Create new solution platforms selected.
  • Add a project configuration with Create new solution configurations selected.
  • Add a new project that will be deployed on multiple platforms, one of which is new.

Solution configurations also provide general project context information to the IDE. For example, if the active solution configuration specifies that a project will be built for a mobile device, the Toolbox will display only project items that can be used in a mobile device project while you are working on that project.

 

项目配置

The project configuration and project platform are used together to specify the properties to use when building the project. A project can have a set of defined project properties for every unique combination of a configuration and platform. Project properties are edited with the Project Designer. Certain panes in the Project Designer contain dropdown lists that indicate the curent project configuration and platform combination.

You can define the configuration-dependent properties in each project configuration as needed. Project properties can be used to determine, for example, which project items will be included in a particular build, what output files will be created, where the output files will be put, and how they will be optimized.

Project configurations can differ considerably. The properties of one project configuration might, for example, specify that its output file be optimized so that the resulting binary occupies the minimum space, while another project might be optimized such that its executable runs at the maximum speed.

Project configurations are not stored by user, but by solution, so that they can be shared by a team. Although project dependencies are configuration-independent, only those projects specified in the active solution configuration will be built.

 

改变解决方案配置

When you build a solution, Visual Studio uses the active solution configuration, which specifies the project configurations to use for each project to be built. You can change the active configuration directly from Solution Configurations drop-down list in the Standard toolbar, or from the Configuration Manager Dialog Box dialog box. 

Note: If you cannot find solution configuration settings on the Standard toolbar or cannot access the Configuration Manager, you may have Visual Basic developer settings applied. For more information, see How to: Manage Build Configurations with Visual Basic Developer Settings Applied. 

 

如何使用IDE为生成分配(Built)项目配置

When you create a new solution configuration (rather than copy one that already exists), the IDE determines the default project configurations for the projects it will build using the following selection criteria for each project (evaluated in this order):

  1. The new solution configuration will build a project configuration whose name exactly matches its own. Configuration names are not case sensitive.

  2. If there is no exact name match, the new solution configuration will build a project configuration whose name matches the configuration portion of its name, whether or not the platform portion also matches. (Remember that the naming convention is <configuration name> <platform-name>.)

  3. If there is still no match, the new solution configuration will build the first configuration listed for a project.

 

如何使用IDE分配项目配置

When you create a project configuration and select Create new solution configurations, the IDE looks for an appropriately named solution configuration to build the project on each platform it supports. In some cases, the IDE will rename existing solution configurations or create new ones.

The IDE determines how to assign solution configurations using the following selection criteria:

  • If a project configuration does not specify a platform or specifies a single platform, then a solution configuration whose name matches that of the new project configuration will either be found or added. In this case, the name of this default solution configuration does not include a platform name; it takes the form <project configuration name>.

  • If a project supports multiple platforms, a solution configuration is found or added for each project configuration to build each project on each platform it supports. The name of each solution configuration includes both the project configuration name and the platform name; it takes the form <project configuration name> <platform name>.

 

如何:创建和编辑配置

Solution build configurations let you select which projects to include in different builds of a project or solution. Project configurations include detailed build and debug settings for each combination of solution build configuration and platform. Creating solution build configurations and project configurations can help you to coordinate your development process with the needs of various user groups, both inside and outside your organization.

Note: The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is described in Help depending on your active settings or edition. This Help page was written with the General Development settings in mind. To view or change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

 

使用配置管理

You can create your own configurations using the Configuration Manager dialog box.

To open the Configuration Manager dialog box
  1. In Solution Explorer, select the solution.
  2. On the Build menu, choose Configuration Manager.

The Configuration Manager dialog box opens.

The Active Solution Configuration drop-down list displays the name of the current solution build configuration. The Active Solution Platform drop-down list displays the name of the current platform for which to build the solution. The Project Contexts pane lists the projects in the solution, the project configurations and platform specified, and check boxes that indicate whether a project will be included when you build or deploy the solution using this configuration.

Once you have configurations created, you can set different properties for your project based on those configurations.

To set properties based on configurations/
  1. In Solution Explorer, select a project.
  2. On the View menu, choose Property Pages.

The Project Property Pages window opens.

You can set different properties based on your configurations. For example, you can create a Release configuration that optimizes code when building the solution, and a Debug configuration that includes the DEBUG conditional compilation symbol. For more information on property page settings, see Managing Project Properties with the Project Designer and Managing C# and J# Projects.

 

使用项目配置

Here are common procedures for creating and managing project configurations:

To create a Project Configuration
  1. Open the Configuration Manager dialog box.
  2. Select a project in the Project column.
  3. Select the Configuration drop-down menu for that project, and choose New. The New Project Configuration dialog box opens.
  4. In the Name text box, type a name for the new configuration.
  5. To use the same property settings as those specified for an existing project configuration, choose a configuration from the Copy settings from drop-down list.
  6. To create a new solution configuration at the same time, select the Create new solution configuration check box. 
To rename a Project Configuration

1.         Open the Configuration Manager dialog box.

2.         Select a project with a project configuration to rename.

3.         On the Configuration drop-down list for that project, choose Edit. The Edit Project Configurations dialog box opens.

4.         Select the project configuration name you want to change.

5.         Select Rename, and then type a new name for the configuration.

 

使用解决方案生成(Build)配置

Here are common procedures for creating and managing solution build configurations:

To create a Solution Build Configuration
  1. Open the Configuration Manager dialog box.
  2. On the Active Solution Configuration drop-down list, choose New. The New Solution Configuration dialog box opens.
  3. Type a name for the new solution build configuration in the Name text box.
  4. To use the same settings as those specified for another solution build configuration, choose one from the drop-down list for the Copy settings from textbox.
  5. If you want to create one or more project configurations at the same time, select the Create new project configurations check box. 
To rename a Solution Build Configuration
  1. Open the Configuration Manager dialog box.
  2. On the Active Solution Configuration drop-down list, choose Edit. The Edit Solution Configurations dialog box opens.
  3. Select the solution build configuration name you want to change.
  4. Select Rename, and then type a new name for the configuration.

To select and edit a Solution Build Configuration

  1. Open the Configuration Manager dialog box.
  2. Select the desired solution build configuration from the Active Solution Configuration drop-down menu at the top of the dialog box. The Project Contexts panes display the properties of the active solution build configuration.
  3. Select any project available in the solution.
  4. Select the desired project Configuration and Platform. Together, these two settings specify the project configuration to be used.
  5. If the project is to be included when you build this solution build configuration, select the Build check box.

原文地址:https://www.cnblogs.com/liuning8023/p/2131485.html