private System.Web.Compilation.BuildProvider GetCompilerParamsAndBuildProvider(VirtualPath virtualPath, out Type codeDomProviderType, out CompilerParameters compilerParameters)
        {
            virtualPath.CombineWithAppRoot();
            CompilationSection compilationConfig    = MTConfigUtil.GetCompilationConfig(virtualPath);
            ICollection        referencedAssemblies = BuildManager.GetReferencedAssemblies(compilationConfig);

            System.Web.Compilation.BuildProvider provider = null;
            if (StringUtil.EqualsIgnoreCase(virtualPath.VirtualPathString, BuildManager.GlobalAsaxVirtualPath.VirtualPathString))
            {
                ApplicationBuildProvider provider2 = new ApplicationBuildProvider();
                provider2.SetVirtualPath(virtualPath);
                provider2.SetReferencedAssemblies(referencedAssemblies);
                provider = provider2;
            }
            else
            {
                provider = BuildManager.CreateBuildProvider(virtualPath, compilationConfig, referencedAssemblies, true);
            }
            provider.IgnoreParseErrors       = true;
            provider.IgnoreControlProperties = true;
            provider.ThrowOnFirstParseError  = false;
            CompilerType codeCompilerType = provider.CodeCompilerType;

            if (codeCompilerType == null)
            {
                codeDomProviderType = null;
                compilerParameters  = null;
                return(null);
            }
            codeDomProviderType = codeCompilerType.CodeDomProviderType;
            compilerParameters  = codeCompilerType.CompilerParameters;
            IAssemblyDependencyParser assemblyDependencyParser = provider.AssemblyDependencyParser;

            if ((assemblyDependencyParser != null) && (assemblyDependencyParser.AssemblyDependencies != null))
            {
                Util.AddAssembliesToStringCollection(assemblyDependencyParser.AssemblyDependencies, compilerParameters.ReferencedAssemblies);
            }
            AssemblyBuilder.FixUpCompilerParameters(codeDomProviderType, compilerParameters);
            return(provider);
        }
        private BuildProvider GetCompilerParamsAndBuildProvider(VirtualPath virtualPath,
                                                                out Type codeDomProviderType, out CompilerParameters compilerParameters)
        {
            virtualPath.CombineWithAppRoot();

            CompilationSection compConfig = MTConfigUtil.GetCompilationConfig(virtualPath);

            ICollection referencedAssemblies = BuildManager.GetReferencedAssemblies(compConfig);

            // Create the buildprovider for the passed in virtualPath
            BuildProvider buildProvider = null;

            // Special case global asax build provider here since we do not want to compile every files with ".asax" extension.
            if (StringUtil.EqualsIgnoreCase(virtualPath.VirtualPathString, BuildManager.GlobalAsaxVirtualPath.VirtualPathString))
            {
                ApplicationBuildProvider provider = new ApplicationBuildProvider();
                provider.SetVirtualPath(virtualPath);
                provider.SetReferencedAssemblies(referencedAssemblies);
                buildProvider = provider;
            }
            else
            {
                buildProvider = BuildManager.CreateBuildProvider(virtualPath, compConfig,
                                                                 referencedAssemblies, true /*failIfUnknown*/);
            }

            // DevDiv 69017
            // The methods restricted to internalBuildProvider have been moved up to BuildProvider
            // to allow WCFBuildProvider to support .svc syntax highlighting.

            // Ignore parse errors, since they should not break the designer
            buildProvider.IgnoreParseErrors = true;

            // Ignore all control properties, since we do not generate code for the properties
            buildProvider.IgnoreControlProperties = true;

            // Process as many errors as possible, do not rethrow on first error
            buildProvider.ThrowOnFirstParseError = false;

            // Get the language (causes the file to be parsed)
            CompilerType compilerType = buildProvider.CodeCompilerType;

            // compilerType could be null in the no-compile case (VSWhidbey 221749)
            if (compilerType == null)
            {
                codeDomProviderType = null;
                compilerParameters  = null;
                return(null);
            }

            // Return the provider type and compiler params
            codeDomProviderType = compilerType.CodeDomProviderType;
            compilerParameters  = compilerType.CompilerParameters;

            IAssemblyDependencyParser parser = buildProvider.AssemblyDependencyParser;

            // Add all the assemblies that the page depends on (e.g. user controls)
            if (parser != null && parser.AssemblyDependencies != null)
            {
                Util.AddAssembliesToStringCollection(parser.AssemblyDependencies,
                                                     compilerParameters.ReferencedAssemblies);
            }

            // Make any fix up adjustments to the CompilerParameters to work around some issues
            AssemblyBuilder.FixUpCompilerParameters(compConfig, codeDomProviderType, compilerParameters);

            return(buildProvider);
        }