protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            if (!Project.InternalCheckNeedsBuild(configuration))
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("Skipping project since output files are up to date"));
                return(new BuildResult());
            }

            DotNetProject project = Project;

            if (!project.TargetRuntime.IsInstalled(project.TargetFramework))
            {
                BuildResult res = new BuildResult();
                res.AddError(GettextCatalog.GetString("Framework '{0}' not installed.", project.TargetFramework.Name));
                return(res);
            }

            bool hasBuildableFiles = false;

            foreach (ProjectFile pf in project.Files)
            {
                if (pf.BuildAction == BuildAction.Compile || pf.BuildAction == BuildAction.EmbeddedResource)
                {
                    hasBuildableFiles = true;
                    break;
                }
            }
            if (!hasBuildableFiles)
            {
                return(new BuildResult());
            }

            if (project.LanguageBinding == null)
            {
                BuildResult langres = new BuildResult();
                string      msg     = GettextCatalog.GetString("Unknown language '{0}'. You may need to install an additional add-in to support this language.", project.LanguageName);
                langres.AddError(msg);
                monitor.ReportError(msg, null);
                return(langres);
            }

            BuildResult           refres         = null;
            HashSet <ProjectItem> itemsToExclude = new HashSet <ProjectItem> ();

            foreach (ProjectReference pr in project.References)
            {
                if (pr.ReferenceType == ReferenceType.Project)
                {
                    // Ignore non-dotnet projects
                    Project p = project.ParentSolution != null?project.ParentSolution.FindProjectByName(pr.Reference) : null;

                    if (p != null && !(p is DotNetProject))
                    {
                        continue;
                    }

                    if (p == null || pr.GetReferencedFileNames(configuration).Length == 0)
                    {
                        if (refres == null)
                        {
                            refres = new BuildResult();
                        }
                        string msg = GettextCatalog.GetString("Referenced project '{0}' not found in the solution.", pr.Reference);
                        monitor.ReportWarning(msg);
                        refres.AddWarning(msg);
                    }
                }

                if (!pr.IsValid)
                {
                    if (refres == null)
                    {
                        refres = new BuildResult();
                    }
                    string msg;
                    if (!pr.IsExactVersion && pr.SpecificVersion)
                    {
                        msg = GettextCatalog.GetString("Reference '{0}' not found on system. Using '{1}' instead.", pr.StoredReference, pr.Reference);
                        monitor.ReportWarning(msg);
                        refres.AddWarning(msg);
                    }
                    else
                    {
                        bool errorsFound = false;
                        foreach (string asm in pr.GetReferencedFileNames(configuration))
                        {
                            if (!File.Exists(asm))
                            {
                                msg = GettextCatalog.GetString("Assembly '{0}' not found. Make sure that the assembly exists in disk. If the reference is required to build the project you may get compilation errors.", Path.GetFileName(asm));
                                refres.AddWarning(msg);
                                monitor.ReportWarning(msg);
                                errorsFound = true;
                                itemsToExclude.Add(pr);
                            }
                        }
                        msg = null;
                        if (!errorsFound)
                        {
                            msg = GettextCatalog.GetString("The reference '{0}' is not valid for the target framework of the project.", pr.StoredReference, pr.Reference);
                            monitor.ReportWarning(msg);
                            refres.AddWarning(msg);
                            itemsToExclude.Add(pr);
                        }
                    }
                }
            }

            DotNetProjectConfiguration conf = (DotNetProjectConfiguration)project.GetConfiguration(configuration);

            // Create a copy of the data needed to compile the project.
            // This data can be modified by extensions.
            // Also filter out items whose condition evaluates to false

            BuildData            buildData = new BuildData();
            ProjectParserContext ctx       = new ProjectParserContext(project, conf);

            buildData.Items = new ProjectItemCollection();
            foreach (ProjectItem item in project.Items)
            {
                if (!itemsToExclude.Contains(item) && (string.IsNullOrEmpty(item.Condition) || ConditionParser.ParseAndEvaluate(item.Condition, ctx)))
                {
                    buildData.Items.Add(item);
                }
            }
            buildData.Configuration = (DotNetProjectConfiguration)conf.Clone();
            buildData.Configuration.SetParentItem(project);
            buildData.ConfigurationSelector = configuration;

            return(ProjectExtensionUtil.Compile(monitor, project, buildData, delegate {
                ProjectItemCollection items = buildData.Items;
                BuildResult res = BuildResources(buildData.Configuration, ref items, monitor);
                if (res != null)
                {
                    return res;
                }

                res = project.LanguageBinding.Compile(items, buildData.Configuration, buildData.ConfigurationSelector, monitor);
                if (refres != null)
                {
                    refres.Append(res);
                    return refres;
                }
                else
                {
                    return res;
                }
            }));
        }
		protected override BuildResult OnBuild (IProgressMonitor monitor, ConfigurationSelector configuration)
		{
			DotNetProject project = Project;
			
			bool hasBuildableFiles = false;
			foreach (ProjectFile pf in project.Files) {
				if (pf.BuildAction == BuildAction.Compile || pf.BuildAction == BuildAction.EmbeddedResource) {
					hasBuildableFiles = true;
					break;
				}
			}
			if (!hasBuildableFiles)
				return new BuildResult ();
			
			if (project.LanguageBinding == null) {
				BuildResult langres = new BuildResult ();
				string msg = GettextCatalog.GetString ("Unknown language '{0}'. You may need to install an additional add-in to support this language.", project.LanguageName);
				langres.AddError (msg);
				monitor.ReportError (msg, null);
				return langres;
			}

			BuildResult refres = null;
			HashSet<ProjectItem> itemsToExclude = new HashSet<ProjectItem> ();
			
			foreach (ProjectReference pr in project.References) {
				
				if (pr.ReferenceType == ReferenceType.Project) {
					// Ignore non-dotnet projects
					Project p = project.ParentSolution != null ? project.ParentSolution.FindProjectByName (pr.Reference) : null;
					if (p != null && !(p is DotNetProject))
						continue;

					if (p == null || pr.GetReferencedFileNames (configuration).Length == 0) {
						if (refres == null)
							refres = new BuildResult ();
						string msg = GettextCatalog.GetString ("Referenced project '{0}' not found in the solution.", pr.Reference);
						monitor.ReportWarning (msg);
						refres.AddWarning (msg);
					}
				}
				
				if (!pr.IsValid) {
					if (refres == null)
						refres = new BuildResult ();
					string msg;
					if (!pr.IsExactVersion && pr.SpecificVersion) {
						msg = GettextCatalog.GetString ("Reference '{0}' not found on system. Using '{1}' instead.", pr.StoredReference, pr.Reference);
						monitor.ReportWarning (msg);
						refres.AddWarning (msg);
					}
					else {
						bool errorsFound = false;
						foreach (string asm in pr.GetReferencedFileNames (configuration)) {
							if (!File.Exists (asm)) {
								msg = GettextCatalog.GetString ("Assembly '{0}' not found. Make sure that the assembly exists in disk. If the reference is required to build the project you may get compilation errors.", Path.GetFileName (asm));
								refres.AddWarning (msg);
								monitor.ReportWarning (msg);
								errorsFound = true;
								itemsToExclude.Add (pr);
							}
						}
						msg = null;
						if (!errorsFound) {
							msg = GettextCatalog.GetString ("The reference '{0}' is not valid for the target framework of the project.", pr.StoredReference, pr.Reference);
							monitor.ReportWarning (msg);
							refres.AddWarning (msg);
							itemsToExclude.Add (pr);
						}
					}
				}
			}
			
			DotNetProjectConfiguration conf = (DotNetProjectConfiguration) project.GetConfiguration (configuration);

			// Create a copy of the data needed to compile the project.
			// This data can be modified by extensions.
			// Also filter out items whose condition evaluates to false
			
			BuildData buildData = new BuildData ();
			ProjectParserContext ctx = new ProjectParserContext (project, conf);
		
			buildData.Items = new ProjectItemCollection ();
			foreach (ProjectItem item in project.Items) {
				if (!itemsToExclude.Contains (item) && (string.IsNullOrEmpty (item.Condition) || ConditionParser.ParseAndEvaluate (item.Condition, ctx)))
					buildData.Items.Add (item);
			}
			buildData.Configuration = (DotNetProjectConfiguration) conf.Clone ();
			buildData.Configuration.SetParentItem (project);
			buildData.ConfigurationSelector = configuration;

			return ProjectExtensionUtil.Compile (monitor, project, buildData, delegate {
				ProjectItemCollection items = buildData.Items;
				BuildResult res = BuildResources (buildData.Configuration, ref items, monitor);
				if (res != null)
					return res;
	
				res = project.LanguageBinding.Compile (items, buildData.Configuration, buildData.ConfigurationSelector, monitor);
				if (refres != null) {
					refres.Append (res);
					return refres;
				}
				else
					return res;
			});
		}