Поделиться через


Building Enterprise Library from the Source Code

Although the Enterprise Library includes binaries for all the source code, you may want to customize the source code. This means you will need to build the Enterprise Library yourself. The following sections describe how to do this. After you have the binaries, you may want to strong name them. For more information about this topic, see Strong Naming the Enterprise Library Assemblies.

This topic contains the following subsections:

  • Installing the Source Code
  • Enterprise Library Visual Studio Solution Files
  • Building the Enterprise Library Application Blocks and Tools
  • Building the Enterprise Library Using Microsoft .Net Framework 4.0
  • Additional Notes for Building and Using the Source Code

Installing the Source Code

You can install all the Enterprise Library source code using the source code Installer. When you run the installer, you can choose to install application blocks, source code, or both.

To run the Source Code Installer

  1. Click Start, point to Programs, point to Microsoft patterns & practices, and then click Enterprise Library 5.0.
  2. Choose Enterprise Library Source Code Installer, and then follow the instructions.

Enterprise Library Visual Studio Solution Files

The Enterprise Library source code contains several Visual Studio projects. Enterprise Library includes multiple Visual Studio 2008 and Visual Studio 2010 solution files. Some of the solution files contain projects for the Enterprise Library Core and all the application blocks, except for projects that have non-standard dependencies (see the following section for details). You can use these solution files to build the entire Enterprise Library or to create solution files that contain only the projects you want to build. When you build the EnterpriseLibrary.sln solution, the core assemblies and the configuration tools are built automatically.

The EnterpriseLibrary.sln solution file contains the entire set of application block projects, Enterprise Library Core projects, and the Configuration Console. However, it does not include optional projects that have non-standard dependencies (such as the Security.AzMan project) or the unit tests. If you want to include the unit tests, you can use the EnterpriseLibrary.Tests.sln solution instead. However, note that this project does not contain the test projects for the Oracle database class.

In addition, there is a solution file for each application block that includes Visual Studio Team System unit tests. The application block solution files contain all the projects, including the provider projects, for the application block. They also contain the configuration design-time projects Microsoft.Practices.EnterpriseLibrary.Configuration.DesignTime and Microsoft.Practices.EnterpriseLibrary.Configuration.EnvironmentalOverrides. The configuration design-time assemblies are required for executing the configuration console, but they are not required for deploying or executing applications.

Build Configurations

The Enterprise Library solution files include two build configurations: Release and Debug. All projects within a solution file, including the unit test projects, are compiled in both configurations.

Building the Enterprise Library Application Blocks and Tools

There are two ways to build the Enterprise Library application blocks and tools. You can use either batch files or Visual Studio solution files. The following sections describe these two options.

Building the Enterprise Library Using Visual Studio 2010 and Microsoft .Net Framework 4.0

When building Enterprise Library from its source code by using the Visual Studio 2010 solutions, the Microsoft .Net Framework. 4.0 Clear Run Time (CLR) is targeted by default. The assemblies which Enterprise Library depends on for a build are located in the lib directory and are by default versions that target Microsoft .Net Framework 3.5. If you want all of your assemblies to target Microsoft .Net Framework 4.0, you must recompile new versions that target Microsoft .Net Framework 4.0 and then update them in the lib directory used by Enterprise Library.

Building the Enterprise Library Using Batch Files

When you install the Enterprise Library source code, the installation program installs several batch files in the \Src\Scripts source code folder. These batch files include the following:

  • BuildLibrary.bat. This file compiles all application blocks and tools. When launched with no parameters, it builds a Debug version of the application blocks and tools. It accepts one parameter to indicate an alternative build type, such as a Release build.
  • CopyAssemblies.bat. This file copies the assemblies to the bin directory. When launched with no parameters, it copies the Debug assemblies to the INSTALLDIR\Program Files\Microsoft Enterprise Library\bin directory. It accepts two parameters. The first parameter indicates an alternative build type, and the second parameter indicates the destination directory where the assemblies will be copied.
  • BuildLibraryAndCopyAssemblies.bat. This file sequentially executes BuildLibrary.bat and CopyAssemblies.bat.

Building Enterprise Library Using Visual Studio Solution Files

You can also use Visual Studio to compile the Enterprise Library application blocks and tools. In Visual Studio, open the EnterpriseLibrary.sln solution file. On the Build menu, click Build Solution. The solution files include the entire set of projects for the application blocks, optional providers, common assemblies, and tools.

The solution files do not copy the assemblies to the bin directory. You can run the batch file CopyAssemblies.bat to copy the assemblies to the source folder bin directory.

Note

To install the instrumentation schema, you can run the InstallServices.bat batch file included in the source folder after you install the source code.

Additional Notes for Building and Using the Source Code

The following are some additional points about building the Enterprise Library:

  • The configuration console requires the application block assemblies to be located in the same directory as the configuration console executable. It requires both the run-time assemblies and the design-time assemblies. Each application packages the design-time support in assemblies that are separate from the run-time implementation. These assemblies are not required for running an application that uses the application blocks. However, they are required when you use the configuration console to change the application block's configuration. Use the CopyAssemblies batch file to place the assemblies into the bin directory.
  • The Enterprise Library configuration console saves fully qualified type information in the application configuration files. When you use the Enterprise Library configuration console with unsigned versions of the application blocks, the PublicKeyToken value for fully qualified types will be null. If you rebuild the application blocks and sign the assemblies, you will have to update the existing application configuration files to incorporate the correct PublicKeyToken value. If you fail to do this, your applications could use incorrect versions of application block assemblies. You can update the configuration files by using the configuration console to open and save them. The configuration console uses signed versions of the application blocks. Alternatively, you can manually edit the configuration files and update the value of the PublicKeyToken.