共用方式為


buildProviders Element for compilation (ASP.NET Settings Schema) 

Defines a collection of build providers that are used to compile custom resource files.

<buildProviders> 
   <add />
   <clear/>
   <remove />
</buildProviders>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

None.

Child Elements

Subtag Description

add

Optional element.

Adds a build provider to the collection.

clear

Optional element.

Removes all references to inherited build providers, allowing only the build providers that are added by the current add element.

remove

Optional element.

Removes a reference to an inherited build provider from the collection.

Parent Elements

Element Description

configuration

Specifies the root element in every configuration file that is used by the common language runtime and the .NET Framework applications.

system.web

Specifies the root element for the ASP.NET configuration section.

compilation

Configures all the compilation settings that ASP.NET uses to compile applications.

Remarks

The buildProviders element defines a collection of build providers that are used to compile custom resource files of a particular file type and to generate code during compilation.

To define custom build actions for a file type within an ASP.NET application, you must derive a class from the BuildProvider class, implement members within the derived class for building the file type, and configure the build provider for the corresponding file extension within the application configuration file. For information, see BuildProvider.

Default Configuration

The following default buildProviders element is not explicitly configured in the Machine.config file or in the root Web.config file. However, it is the default configuration that is returned by application. Items are added to the buildProviders collection in the root Web.config file.

<buildProviders>
   <clear />
</buildProviders>

The following default buildProviders element is configured in the root Web.config file.

<buildProviders>
   <add extension=".aspx" type="System.Web.Compilation.PageBuildProvider"/>
   <add extension=".ascx" type="System.Web.Compilation.UserControlBuildProvider"/>
   <add extension=".master" type="System.Web.Compilation.MasterPageBuildProvider"/>
   <add extension=".asix" type="System.Web.Compilation.ImageGeneratorBuildProvider"/>
   <add extension=".asmx" type="System.Web.Compilation.WebServiceBuildProvider"/>
   <add extension=".ashx" type="System.Web.Compilation.WebHandlerBuildProvider"/>
   <add extension=".soap" type="System.Web.Compilation.WebServiceBuildProvider"/>
   <add extension=".resx" type="System.Web.Compilation.ResXBuildProvider"/>
   <add extension=".resources" type="System.Web.Compilation.ResourcesBuildProvider"/>
   <add extension=".wsdl" type="System.Web.Compilation.WsdlBuildProvider"/>
   <add extension=".xsd" type="System.Web.Compilation.XsdBuildProvider"/>
   <add extension=".js" type="System.Web.Compilation.ForceCopyBuildProvider"/>
</buildProviders>

Example

The following code example demonstrates how to define a build provider that is used to compile custom resource files with the specified extension.

<configuration>
   <system.web>
      <compilation>
         <buildProviders>
            <buildProvider 
               extension=".mafx" 
               type="MyBuildProviderType, MyBuildProviderAssembly" />
         </buildProviders>
      </compilation>
   </system.web>
</configuration>

Element Information

Configuration section handler

CompilationSection

Configuration member

BuildProviders

BuildProviderCollection

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Virtual or physical directory–level Web.config

Requirements

Microsoft Internet Information Services (IIS) 5.0, 5.1, or 6.0

The .NET Framework 2.0

Microsoft Visual Studio 2003 or Visual Studio 2005

See Also

Tasks

How to: Configure Specific Directories Using Location Settings
How to: Lock ASP.NET Configuration Settings

Reference

compilation Element (ASP.NET Settings Schema)
add Element for buildProviders for compilation (ASP.NET Settings Schema)
clear Element for buildProviders for compilation (ASP.NET Settings Schema)
remove Element for buildProviders for compilation (ASP.NET Settings Schema)
assemblies Element for compilation (ASP.NET Settings Schema)
codeSubDirectories Element for compilation (ASP.NET Settings Schema)
compilers Element for compilation (ASP.NET Settings Schema)
expressionBuilders Element for compilation (ASP.NET Settings Schema)
configuration Element (General Settings Schema)
system.web Element (ASP.NET Settings Schema)
System.Configuration
System.Web.Configuration
CompilationSection
BuildProviders
BuildProviderCollection

Concepts

ASP.NET Compilation Model
ASP.NET Web Page Code Model
ASP.NET Web Site Precompilation Overview
ASP.NET Configuration File Hierarchy and Inheritance
Securing ASP.NET Configuration
ASP.NET Configuration Scenarios

Other Resources

General Configuration Settings (ASP.NET)
ASP.NET Configuration Settings
Configuring ASP.NET Applications
ASP.NET Configuration Files
ASP.NET Configuration API