A System.Web.Compilation.BuildProvider implementation calls the AssemblyBuilder.AddCodeCompileUnit(BuildProvider, System.CodeDom.CodeCompileUnit) method when generating a CodeDOM graph for a virtual path. Source code added with AssemblyBuilder.AddCodeCompileUnit(BuildProvider, System.CodeDom.CodeCompileUnit) is included in the assembly compilation.
Typically, a build provider's BuildProvider.GenerateCode(AssemblyBuilder) method implementation reads the BuildProvider.VirtualPath property, parses the contents, and then adds the generated source code to the specified System.Web.Compilation.AssemblyBuilder object. The build provider uses the AssemblyBuilder.AddCodeCompileUnit(BuildProvider, System.CodeDom.CodeCompileUnit) method to add source code as a CodeDOM graph to the assembly. Alternately, the build provider can use the AssemblyBuilder.CreateCodeFile(BuildProvider) method to add source code as a physical file to the assembly.