Building Enterprise Library from the Source Code

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

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
  • Additional Notes for Building and Using the Source Code
  • Building the QuickStart Applications

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, QuickStarts, or both.

To run the Source Code Installer

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

Library Visual Studio Solution Files

The Enterprise Library source code contains several Visual Studio projects. Enterprise Library includes multiple Visual Studio 2008 solution files (and, for the Unity Application Block, a Visual Studio 2005 solution file). Three of the solution files contain projects for the Enterprise Library Core and all the application blocks, minus certain projects that have non-standard dependencies (see the following notes). 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 Enterprise Library, the Core and Configuration Console are built automatically. The EnterpriseLibrary.sln solution file contains the entire set of application block projects, Enterprise Library Core projects, and the Configuration Console. It also includes all unit tests for execution with Visual Studio Team System.

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. The configuration design-time assemblies are required for executing the Configuration Console, but they are not required for deploying or executing applications.

Note

The Security Application Block includes an authorization provider for Authorization Manager (AzMan). This provider requires AzMan to be installed and also requires the interop assembly, Microsoft.Interop.Security.AzRoles.dll. The Enterprise Library solution file does not contain the run-time projects and design-time projects for the AzMan authorization provider. If you want to compile the AzMan provider projects, you can modify the Enterprise Library solution files or you can use the Security Application Block solution files.

Similarly, the Enterprise Library solution files do not contain the following projects: ExceptionHandling.WCF, Validation.Integration.WCF, and Data.SqlCe. These projects can be found in their respective solution files.

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 Batch Files

When you install the Enterprise Library source code, the installation program installs several batch files in the 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 (EntLibConfig.exe). 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. All the required assemblies have the suffix .configuration.design.dll. 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.

The Security Application Block includes an authorization provider for Authorization Manager (AzMan). This provider requires AzMan to be installed and also requires the interop assembly, Microsoft.Interop.Security.AzRoles.dll. If you do not have AzMan installed locally with the interop assembly, you will see an error message when you build the Security Application Block solution files. The error message indicates that the type or namespace name "Interop" does not exist in the class or namespace "Microsoft." This error is expected when AzMan is not installed, and you can ignore it. The Security Application Block will build successfully, but the AzMan provider will not be available.

The Enterprise Library solution file does not contain the following run-time projects and design-time projects:

  • ExceptionHandling.WCF
  • Validation.Integration.WCF
  • Data.SqlCe

These projects can be found in their respective solution files.

The Enterprise Library solution file does not contain the AzMan projects. These projects require an assembly that is shipped as part of Windows 2005 and 2008.

Building the QuickStart Applications

The QuickStart projects are not included in the Enterprise Library solution files. Each QuickStart has a solution file that includes the QuickStart projects and all required application block projects. To build a QuickStart, open the appropriate QuickStart solution file in Visual Studio, and then click Build Solution on the Build menu.