protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem project, ConfigurationSelector configuration)
        {
            var aspProject = project as AspNetAppProject;

            //get the config object and validate
            AspNetAppProjectConfiguration config = (AspNetAppProjectConfiguration)aspProject.GetConfiguration(configuration);

            if (config == null || config.DisableCodeBehindGeneration)
            {
                return(base.Build(monitor, project, configuration));
            }

            var writer = CodeBehindWriter.CreateForProject(monitor, aspProject);

            if (!writer.SupportsPartialTypes)
            {
                return(base.Build(monitor, project, configuration));
            }

            var result = new BuildResult();

            monitor.BeginTask("Updating CodeBehind designer files", 0);

            foreach (var file in aspProject.Files)
            {
                ProjectFile designerFile = CodeBehind.GetDesignerFile(file);
                if (designerFile == null)
                {
                    continue;
                }

                if (File.GetLastWriteTimeUtc(designerFile.FilePath) > File.GetLastWriteTimeUtc(file.FilePath))
                {
                    continue;
                }

                monitor.Log.WriteLine("Updating CodeBehind for file '{0}'", file);
                result.Append(CodeBehind.UpdateDesignerFile(writer, aspProject, file, designerFile));
            }

            writer.WriteOpenFiles();

            monitor.EndTask();

            if (writer.WrittenCount > 0)
            {
                monitor.Log.WriteLine("{0} CodeBehind designer classes updated.", writer.WrittenCount);
            }
            else
            {
                monitor.Log.WriteLine("No changes made to CodeBehind classes.");
            }

            if (result.Failed)
            {
                return(result);
            }

            return(result.Append(base.Build(monitor, project, configuration)));
        }
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem project, ConfigurationSelector configuration)
        {
            AspNetAppProject aspProject = project as AspNetAppProject;

            //get the config object and validate
            AspNetAppProjectConfiguration config = (AspNetAppProjectConfiguration)aspProject.GetConfiguration(configuration);

            if (config == null)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString
                                          ("Project configuration is invalid. Skipping CodeBehind member generation."));
                return(base.Build(monitor, project, configuration));
            }

            if (config.DisableCodeBehindGeneration)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString
                                          ("Skipping updating of CodeBehind partial classes, because this feature is disabled."));
                return(base.Build(monitor, project, configuration));
            }

            CodeBehindWriter writer = CodeBehindWriter.CreateForProject(monitor, aspProject);

            if (!writer.SupportsPartialTypes)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString
                                          ("The code generator for {0} does not support partial classes. Skipping CodeBehind member generation.",
                                          aspProject.LanguageBinding.Language));
                ;
                return(base.Build(monitor, project, configuration));
            }

            //get the extension used for codebehind files
            string langExt = aspProject.LanguageBinding.GetFileName("a");

            langExt = langExt.Substring(1, langExt.Length - 1);

            List <CodeBehindWarning> errors = new List <CodeBehindWarning> ();

            monitor.Log.WriteLine(GettextCatalog.GetString("Generating CodeBehind members..."));

            bool updatedParseDb = false;

            //go over all the files generating members where necessary
            foreach (ProjectFile file in aspProject.Files)
            {
                WebSubtype type = AspNetAppProject.DetermineWebSubtype(file.FilePath);
                if (type != WebSubtype.WebForm && type != WebSubtype.WebControl && type != WebSubtype.MasterPage)
                {
                    continue;
                }

                //find the designer file
                ProjectFile designerFile = aspProject.Files.GetFile(file.Name + ".designer" + langExt);
                if (designerFile == null)
                {
                    aspProject.Files.GetFile(file.Name + ".Designer" + langExt);
                }
                if (designerFile == null)
                {
                    continue;
                }

                //only regenerate the designer class if it's older than the aspx (etc) file
                if (System.IO.File.GetLastWriteTimeUtc(designerFile.FilePath)
                    > System.IO.File.GetLastWriteTimeUtc(file.FilePath))
                {
                    continue;
                }

                //need parse DB to be up to date
                if (!updatedParseDb)
                {
                    updatedParseDb = true;
                    monitor.Log.Write(GettextCatalog.GetString("Waiting for project type database to finish updating..."));
                    //var dom = TypeSystemService.GetContext (aspProject);
                    //TypeSystemService.ForceUpdate (dom);
                    monitor.Log.WriteLine(GettextCatalog.GetString(" complete."));
                }

                //parse the ASP.NET file
                var parsedDocument = TypeSystemService.ParseFile(aspProject, file.FilePath) as AspNetParsedDocument;
                if (parsedDocument == null)
                {
                    continue;
                }

                var ccu = CodeBehind.GenerateCodeBehind(aspProject, designerFile.FilePath, parsedDocument, errors);
                if (ccu == null)
                {
                    continue;
                }

                writer.WriteFile(designerFile.FilePath, ccu);
            }

            writer.WriteOpenFiles();

            //write out a friendly message aout what we did
            if (writer.WrittenCount > 0)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("{0} CodeBehind designer classes updated.", writer.WrittenCount));
            }
            else
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("No changes made to CodeBehind classes."));
            }

            //and construct and return a build result
            BuildResult baseResult = base.Build(monitor, project, configuration);

            foreach (CodeBehindWarning cbw in errors)
            {
                if (cbw.FileName != null)
                {
                    baseResult.AddWarning(cbw.FileName, cbw.Line, cbw.Column, null, cbw.WarningText);
                }
                else
                {
                    baseResult.AddWarning(cbw.WarningText);
                }
            }
            return(baseResult);
        }