示例#1
0
        public void ReportSuccess(string message)
        {
            if (ReportGlobalDataToParent && parentMonitor != null)
            {
                parentMonitor.ReportSuccess(message);
            }
            lock (messages)
                messages.Add(message);

            if (context != null)
            {
                context.Post((o) => OnSuccessReported(message), null);
            }
            else
            {
                OnSuccessReported(message);
            }

            if (followerMonitors != null)
            {
                foreach (var sm in followerMonitors)
                {
                    sm.ReportSuccess(message);
                }
            }
        }
示例#2
0
        public void ReportSuccess(string message)
        {
            if (ReportGlobalDataToParent && parentMonitor != null)
            {
                parentMonitor.ReportSuccess(message);
            }
            lock (messages)
                messages.Add(message);

            if (context != null)
            {
                context.Post((o) => {
                    var(mon, msg) = (ValueTuple <ProgressMonitor, string>)o;
                    mon.OnSuccessReported(msg);
                }, (this, message));
            }
            else
            {
                OnSuccessReported(message);
            }

            if (followerMonitors != null)
            {
                foreach (var sm in followerMonitors)
                {
                    sm.ReportSuccess(message);
                }
            }
        }
		void RestorePackages (ProgressMonitor progressMonitor, ProgressMonitorStatusMessage progressMessage)
		{
			var msbuildTargetsMonitor = new MSBuildTargetsRestoredMonitor (packageManagementEvents);
			using (msbuildTargetsMonitor) {
				var action = new RestorePackagesAction (solution, packageManagementEvents);
				if (project != null) {
					action.Project = project;
				}
				action.Execute ();
			}

			RefreshProjectReferences (msbuildTargetsMonitor.AnyMSBuildTargetsRestored);
			ForceCreationOfSharedRepositoriesConfigFile ();

			progressMonitor.ReportSuccess (progressMessage.Success);
			packageManagementEvents.OnPackagesRestored ();
		}
示例#4
0
		static bool UpdateCompleted (ProgressMonitor monitor,
		                             ProjectFile file, ProjectFile genFile, SingleFileCustomToolResult result,
		                             bool runMultipleFiles)
		{
			monitor.EndTask ();

			if (monitor.CancellationToken.IsCancellationRequested) {
				monitor.ReportError (GettextCatalog.GetString ("Cancelled"), null);
				monitor.Dispose ();
				return false;
			}
			
			string genFileName;
			try {
				
				bool broken = false;
				
				if (result.UnhandledException != null) {
					broken = true;
					string msg = GettextCatalog.GetString ("The '{0}' code generator crashed", file.Generator);
					result.Errors.Add (new CompilerError (file.Name, 0, 0, "", msg + ": " + result.UnhandledException.Message));
					monitor.ReportError (msg, result.UnhandledException);
					LoggingService.LogError (msg, result.UnhandledException);
				}

				genFileName = result.GeneratedFilePath.IsNullOrEmpty?
					null : result.GeneratedFilePath.ToRelative (file.FilePath.ParentDirectory);
				
				if (!string.IsNullOrEmpty (genFileName)) {
					bool validName = genFileName.IndexOfAny (new [] { '/', '\\' }) < 0
						&& FileService.IsValidFileName (genFileName);
					
					if (!broken && !validName) {
						broken = true;
						string msg = GettextCatalog.GetString ("The '{0}' code generator output invalid filename '{1}'",
						                                       file.Generator, result.GeneratedFilePath);
						result.Errors.Add (new CompilerError (file.Name, 0, 0, "", msg));
						monitor.ReportError (msg, null);
					}
				}
				
				if (result.Errors.Count > 0) {
					DispatchService.GuiDispatch (delegate {
						foreach (CompilerError err in result.Errors)
							TaskService.Errors.Add (new TaskListEntry (file.FilePath, err.ErrorText, err.Column, err.Line,
								err.IsWarning? TaskSeverity.Warning : TaskSeverity.Error,
								TaskPriority.Normal, file.Project.ParentSolution, file));
					});
				}
				
				if (broken)
					return true;

				if (!runMultipleFiles) {
					if (result.Success)
						monitor.ReportSuccess ("Generated file successfully.");
					else if (result.SuccessWithWarnings)
						monitor.ReportSuccess ("Warnings in file generation.");
					else
						monitor.ReportError ("Errors in file generation.", null);
				}
			} finally {
				if (!runMultipleFiles)
					monitor.Dispose ();
			}

			if (result.GeneratedFilePath.IsNullOrEmpty || !File.Exists (result.GeneratedFilePath))
				return true;

			// broadcast a change event so text editors etc reload the file
			FileService.NotifyFileChanged (result.GeneratedFilePath);

			// add file to project, update file properties, etc
			Gtk.Application.Invoke (async delegate {
				bool projectChanged = false;
				if (genFile == null) {
					genFile = file.Project.AddFile (result.GeneratedFilePath, result.OverrideBuildAction);
					projectChanged = true;
				} else if (result.GeneratedFilePath != genFile.FilePath) {
					genFile.Name = result.GeneratedFilePath;
					projectChanged = true;
				}

				if (file.LastGenOutput != genFileName) {
					file.LastGenOutput = genFileName;
					projectChanged = true;
				}

				if (genFile.DependsOn != file.FilePath.FileName) {
					genFile.DependsOn = file.FilePath.FileName;
					projectChanged = true;
				}

				if (projectChanged)
					await IdeApp.ProjectOperations.SaveAsync (file.Project);
			});

			return true;
		}
示例#5
0
		static void WriteSummaryResults (ProgressMonitor monitor, int succeeded, int warnings, int errors)
		{
			monitor.Log.WriteLine ();

			int total = succeeded + warnings + errors;

			//this might not be correct for languages where pluralization affects the other arguments
			//but gettext doesn't really have an answer for sentences with multiple plurals
			monitor.Log.WriteLine (
				GettextCatalog.GetPluralString (
					"{0} file processed total. {1} generated successfully, {2} with warnings, {3} with errors",
					"{0} files processed total. {1} generated successfully, {2} with warnings, {3} with errors",
					total,
					total, succeeded, warnings, errors)
			);
			//ends the root task
			monitor.EndTask ();

			if (errors > 0)
				monitor.ReportError (GettextCatalog.GetString ("Errors in file generation."), null);
			else if (warnings > 0)
				monitor.ReportSuccess (GettextCatalog.GetString ("Warnings in file generation."));
			else
				monitor.ReportSuccess (GettextCatalog.GetString ("Generated files successfully."));

			monitor.Dispose ();
		}
		public void Push (ProgressMonitor monitor, string remote, string remoteBranch)
		{
			bool success = true;

			var branch = RootRepository.Head;
			if (branch.TrackedBranch == null) {
				RootRepository.Branches.Update (branch, b => b.TrackedBranch = "refs/remotes/" + remote + "/" + remoteBranch);
			}

			RetryUntilSuccess (monitor, credType =>
				RootRepository.Network.Push (RootRepository.Network.Remotes [remote], "refs/heads/" + remoteBranch, new PushOptions {
					OnPushStatusError = pushStatusErrors => success = false,
					CredentialsProvider = (url, userFromUrl, types) => GitCredentials.TryGet (url, userFromUrl, types, credType)
				})
			);

			if (!success)
				return;

			monitor.ReportSuccess (GettextCatalog.GetString ("Push operation successfully completed."));
		}
		protected async override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
		{
			if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.CleanTargetName)) {
				return await base.OnClean (monitor, configuration, operationContext); 
			}

			monitor.BeginTask ( GettextCatalog.GetString( "Cleaning project"), 1);
			try
			{
				string baseDir = Project.BaseDirectory;
	
				ProcessWrapper process = Runtime.ProcessService.StartProcess ( "make", 
						data.CleanTargetName,
						baseDir, 
						monitor.Log, 
						monitor.Log, 
						null );

				await process.Task;

				if ( process.ExitCode > 0 )
					throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0}'", "make " + data.CleanTargetName) );

				monitor.Step ( 1 );
			}
			catch ( Exception e )
			{
				monitor.ReportError ( GettextCatalog.GetString ("Project could not be cleaned: "), e );
				var res = new BuildResult ();
				res.AddError (GettextCatalog.GetString ("Project could not be cleaned: ") + e.Message);
				return res;
			}
			finally 
			{
				monitor.EndTask ();
			}
			monitor.ReportSuccess ( GettextCatalog.GetString ( "Project successfully cleaned"));
			return BuildResult.CreateSuccess ();
		}
		public bool GenerateFiles (DeployContext ctx, Solution solution, string defaultConf, ProgressMonitor monitor )
		{
			string filesString = generateAutotools ? "Autotools files" : "Makefiles";
			monitor.BeginTask ( GettextCatalog.GetString ("Generating {0} for Solution {1}", filesString, solution.Name), 1 );

			try
			{
				solution_dir = Path.GetDirectoryName(solution.FileName);

				string[] configs = new string [ solution.Configurations.Count ];
				for (int ii=0; ii < configs.Length; ii++ )
					configs [ii] = solution.Configurations[ii].Id;
					
				MakefileType mt = generateAutotools ? MakefileType.AutotoolsMakefile : MakefileType.SimpleMakefile;
				
				context = new AutotoolsContext ( ctx, solution_dir, configs, mt );
				context.TargetSolution = solution;
				context.Switches = switchs;
				
				IMakefileHandler handler = AutotoolsContext.GetMakefileHandler (solution.RootFolder, mt);
				if (handler == null)
					throw new Exception (string.Format (
						"{0} does not currently support generating {1} for one (or more) child projects.",
						filesString, BrandingService.ApplicationName
					));

				solution_name = solution.Name;
				solution_version = AutotoolsContext.EscapeStringForAutoconf (solution.Version, true);
				if (string.IsNullOrEmpty (solution_version))
					solution_version = "0.1";

				Makefile makefile = handler.Deploy ( context, solution.RootFolder, monitor );
				string path = Path.Combine (solution_dir, "Makefile");
				if (generateAutotools) {
					context.AddAutoconfFile (path);
					CreateAutoGenDotSH (context, monitor);
					CreateConfigureDotAC (solution, defaultConf, monitor, context);
					CreateMacros ();
				} else {
					CreateConfigureScript (solution, defaultConf, context, monitor);

					monitor.Log.WriteLine ( GettextCatalog.GetString ("Creating rules.make"));
					string rules_make_path = Path.Combine (solution_dir, "rules.make");
					File.Copy (Path.Combine (context.TemplateDir, "rules.make"), rules_make_path, true);
					context.AddGeneratedFile (rules_make_path);
				}

				CreateMakefileInclude ( context, monitor );
				AddTopLevelMakefileVars ( makefile, monitor );

				if (generateAutotools)
					path = path + ".am";
				StreamWriter writer = new StreamWriter (path);
				makefile.Write ( writer );
				writer.Close ();

				context.AddGeneratedFile (path);

				monitor.ReportSuccess ( GettextCatalog.GetString ("{0} were successfully generated.", filesString ) );
				monitor.Step (1);
			}
			catch ( Exception e )
			{
				monitor.ReportError ( GettextCatalog.GetString ("{0} could not be generated: ", filesString ), e );
				LoggingService.LogError (GettextCatalog.GetString ("{0} could not be generated: ", filesString ), e);
				DeleteGeneratedFiles ( context );
				return false;
			}
			finally
			{
				monitor.EndTask ();
			}
			return true;
		}
		void BuildDone (ProgressMonitor monitor, BuildResult result, IBuildTarget entry, ITimeTracker tt)
		{
			TaskListEntry[] tasks = null;
			tt.Trace ("Begin reporting build result");
			try {
				if (result != null) {
					lastResult = result;
					monitor.Log.WriteLine ();
					monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------"));
					
					tt.Trace ("Updating task service");

					tasks = ReportErrors (result);

					tt.Trace ("Reporting result");
					
					string errorString = GettextCatalog.GetPluralString("{0} error", "{0} errors", result.ErrorCount, result.ErrorCount);
					string warningString = GettextCatalog.GetPluralString("{0} warning", "{0} warnings", result.WarningCount, result.WarningCount);

					if (monitor.CancellationToken.IsCancellationRequested) {
						monitor.ReportError (GettextCatalog.GetString ("Build canceled."), null);
					} else if (result.ErrorCount == 0 && result.WarningCount == 0 && lastResult.FailedBuildCount == 0) {
						monitor.ReportSuccess (GettextCatalog.GetString ("Build successful."));
					} else if (result.ErrorCount == 0 && result.WarningCount > 0) {
						monitor.ReportWarning(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString);
					} else if (result.ErrorCount > 0) {
						monitor.ReportError(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString, null);
					} else {
						monitor.ReportError(GettextCatalog.GetString("Build failed."), null);
					}
					tt.Trace ("End build event");
					OnEndBuild (monitor, lastResult.FailedBuildCount == 0, lastResult, entry as SolutionFolderItem);
				} else {
					tt.Trace ("End build event");
					OnEndBuild (monitor, false);
				}
				
				tt.Trace ("Showing results pad");
				
				ShowErrorsPadIfNecessary ();

				if (tasks != null) {
					TaskListEntry jumpTask = null;
					switch (IdeApp.Preferences.JumpToFirstErrorOrWarning.Value) {
					case JumpToFirst.Error:
						jumpTask = tasks.FirstOrDefault (t => t.Severity == TaskSeverity.Error && TaskStore.IsProjectTaskFile (t));
						break;
					case JumpToFirst.ErrorOrWarning:
						jumpTask = tasks.FirstOrDefault (t => (t.Severity == TaskSeverity.Error || t.Severity == TaskSeverity.Warning) && TaskStore.IsProjectTaskFile (t));
						break;
					}
					if (jumpTask != null) {
						tt.Trace ("Jumping to first result position");
						jumpTask.JumpToPosition ();
					}
				}
				
			} finally {
				monitor.Dispose ();
				tt.End ();
			}
		}
		void CheckForPackageUpdates (
			ProgressMonitor progressMonitor,
			ProgressMonitorStatusMessage progressMessage,
			PackageUpdatesEventMonitor eventMonitor)
		{
			updatedPackagesInSolution.CheckForUpdates ();
			if (updatedPackagesInSolution.AnyUpdates ()) {
				progressMonitor.ReportSuccess (GettextCatalog.GetString ("Package updates are available."));
			} else if (eventMonitor.WarningReported) {
				progressMonitor.ReportWarning (progressMessage.Warning);
			} else {
				progressMonitor.ReportSuccess (progressMessage.Success);
			}
		}
		void CleanDone (ProgressMonitor monitor, BuildResult result, IBuildTarget entry, ITimeTracker tt)
		{
			tt.Trace ("Begin reporting clean result");
			try {
				if (result != null) {
					monitor.Log.WriteLine ();
					monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------"));

					tt.Trace ("Updating task service");
				
					ReportErrors (result);

					tt.Trace ("Reporting result");

					string errorString = GettextCatalog.GetPluralString ("{0} error", "{0} errors", result.ErrorCount, result.ErrorCount);
					string warningString = GettextCatalog.GetPluralString ("{0} warning", "{0} warnings", result.WarningCount, result.WarningCount);

					if (monitor.CancellationToken.IsCancellationRequested) {
						monitor.ReportError (GettextCatalog.GetString ("Clean canceled."), null);
					} else if (result.ErrorCount == 0 && result.WarningCount == 0 && result.FailedBuildCount == 0) {
						monitor.ReportSuccess (GettextCatalog.GetString ("Clean successful."));
					} else if (result.ErrorCount == 0 && result.WarningCount > 0) {
						monitor.ReportWarning (GettextCatalog.GetString ("Clean: ") + errorString + ", " + warningString);
					} else if (result.ErrorCount > 0) {
						monitor.ReportError (GettextCatalog.GetString ("Clean: ") + errorString + ", " + warningString, null);
					} else {
						monitor.ReportError (GettextCatalog.GetString ("Clean failed."), null);
					}
				}

				OnEndClean (monitor, tt);

				tt.Trace ("Showing results pad");

				ShowErrorsPadIfNecessary ();

			} finally {
				monitor.Dispose ();
				tt.End ();
			}
		}
		public Translation AddNewTranslation (string isoCode, ProgressMonitor monitor)
		{
			try {
				Translation tr = new Translation (this, isoCode);
				translations.Add (tr);
				string templateFile    = Path.Combine (this.BaseDirectory, "messages.po");
				string translationFile = GetFileName (isoCode);
				if (!File.Exists (templateFile)) 
					CreateDefaultCatalog (monitor);
				File.Copy (templateFile, translationFile);
				
				monitor.ReportSuccess (String.Format (GettextCatalog.GetString ("Language '{0}' successfully added."), isoCode));
				monitor.Step (1);
				SaveAsync (monitor);
				return tr;
			} catch (Exception e) {
				monitor.ReportError (String.Format ( GettextCatalog.GetString ("Language '{0}' could not be added: "), isoCode), e);
				return null;
			} finally {
				monitor.EndTask ();
			}
		}
        public void SaveModule(FilePath file, ProgressMonitor monitor)
        {
            try {
                monitor.BeginTask ("Saving module " + latestModuleInfo.Name + "...", 1);
				monitor.BeginStep();

                if (this.SingleStartup) {
                    latestModuleInfo.DefaultStartupProject = this.StartupItem.Name;
                }

                appDomain.SaveModule (latestModuleInfo);
            }
            catch (Exception ex) {
                monitor.ReportError ("Failed to save module " + latestModuleInfo.Name, ex);
                throw;
            }
            finally {
                monitor.ReportSuccess ("Saved module " + latestModuleInfo.Name);
                monitor.EndTask ();
            }

			DefinitionOrModuleSaved();
        }
		void CleanDone (ProgressMonitor monitor, IBuildTarget entry, ITimeTracker tt)
		{
			tt.Trace ("Begin reporting clean result");
			try {
				monitor.Log.WriteLine ();
				monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------"));
				tt.Trace ("Reporting result");			
				monitor.ReportSuccess (GettextCatalog.GetString ("Clean successful."));
				OnEndClean (monitor, tt);
			} finally {
				monitor.Dispose ();
				tt.End ();
			}
		}
示例#15
0
		async Task AddXwtFromGithubAsync (Solution solution, string newProjectName, bool createSubmodule, ProgressMonitor monitor)
		{
			try {
				var gitUrl = "https://github.com/" + (string.IsNullOrEmpty (Parameters ["XwtGithubRepository"]) ? Parameters ["XwtGithubRepository"] : "mono/xwt") + ".git";
				var gitBranch = Parameters ["XwtGithubBranch"];
				if (gitBranch == String.Empty)
					gitBranch = "master";
				var gitRepo = VersionControlService.GetRepository (solution) as GitRepository;
				var xwt_proj = solution.FindProjectByName ("Xwt") as DotNetProject;

				if (xwt_proj != null && xwt_proj.ItemId.ToUpper () != "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
					xwt_proj = null;
					foreach (var item in solution.GetAllProjectsWithFlavor<DotNetProjectExtension>()) {
						if (item.ItemId.ToUpper () == "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
							xwt_proj = item as DotNetProject;
							break;
						}
					}
				}

				var xwt_path = xwt_proj == null ? solution.BaseDirectory.Combine ("Xwt") : xwt_proj.BaseDirectory.ParentDirectory;

				monitor.BeginTask ("Configuring Xwt References...", 3);

				if (xwt_proj == null && !Directory.Exists (xwt_path)) {
					monitor.BeginTask ("Cloning Xwt into " + xwt_path + "...", 1);
					if (createSubmodule && gitRepo != null) {
						monitor.BeginTask ("Initializing Xwt submodule in " + xwt_path + "...", 1);

						var repo = new FileRepository (gitRepo.RootPath.Combine (".git"));
						var git = new Git (repo);

						try {
							using (var gm = new GitMonitor (monitor)) {
								var add_submodule = git.SubmoduleAdd ();
								add_submodule.SetPath ("Xwt");
								add_submodule.SetURI (gitUrl);
								add_submodule.SetProgressMonitor (gm);
								add_submodule.Call ();

								var submodule = new GitRepository (VersionControlService.GetVersionControlSystems ().First (id => id.Name == "Git"),
												   gitRepo.RootPath.Combine ("Xwt"), gitUrl);

								var submoduleRemote = submodule.GetCurrentRemote ();
								submodule.Fetch (monitor, submoduleRemote);
								if (submodule.GetCurrentBranch () != gitBranch) {
									submodule.CreateBranch (gitBranch, submoduleRemote + "/" + gitBranch, "refs/remotes/" + submoduleRemote + "/" + gitBranch);
									submodule.SwitchToBranch (monitor, gitBranch);
								}
							}
						} catch {
							Directory.Delete (xwt_path, true);
							throw;
						}

						monitor.EndTask ();
					} else {

						var repo = new GitRepository ();
						repo.Url = gitUrl;
						repo.Checkout (xwt_path, true, monitor);
						var remote = repo.GetCurrentRemote ();
						repo.Fetch (monitor, remote);
						if (repo.GetCurrentBranch () != gitBranch) {
							repo.CreateBranch (gitBranch, remote + "/" + gitBranch, "refs/remotes/" + remote + "/" + gitBranch);
							repo.SwitchToBranch (monitor, gitBranch);
						}
					}
					monitor.EndTask ();
				}

				SolutionFolder xwt_folder;
				if (xwt_proj != null)
					xwt_folder = xwt_proj.ParentFolder;
				else {
					xwt_folder = new SolutionFolder ();
					xwt_folder.Name = "Xwt";
				}
				solution.RootFolder.Items.Add (xwt_folder);
				monitor.Step (1);

				monitor.BeginTask ("Adding Xwt Projects to Solution...", 7);

				if (xwt_proj == null && File.Exists (xwt_path.Combine ("Xwt", "Xwt.csproj"))) {
					xwt_proj = await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt", "Xwt.csproj")
					) as DotNetProject;
				}
				if (xwt_proj == null)
					throw new InvalidOperationException ("Xwt project not found");

				monitor.Step (1);

				var xwt_gtk_proj = solution.FindProjectByName ("Xwt.Gtk") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk_win_proj = solution.FindProjectByName ("Xwt.Gtk.Windows") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk.Windows", "Xwt.Gtk.Windows.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk_mac_proj = solution.FindProjectByName ("Xwt.Gtk.Mac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk.Mac", "Xwt.Gtk.Mac.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk3_proj = solution.FindProjectByName ("Xwt.Gtk3") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk3.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_wpf_proj = solution.FindProjectByName ("Xwt.WPF") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.WPF", "Xwt.WPF.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_mac_proj = solution.FindProjectByName ("Xwt.Mac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Mac", "Xwt.Mac.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_xammac_proj = solution.FindProjectByName ("Xwt.XamMac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.XamMac", "Xwt.XamMac.csproj")
					) as DotNetProject;


				monitor.EndTask ();
				monitor.Step (1);
				monitor.BeginTask ("Adding Xwt References...", solution.Items.Count);

				foreach (var item in solution.Items) {
					var project = item as DotNetProject;
					if (project != null) {
						if (project.Name == newProjectName ||
						    project.Name.StartsWith (newProjectName + ".", StringComparison.Ordinal))
							project.References.Add (ProjectReference.CreateProjectReference (xwt_proj));
						
						if (project.Name == newProjectName + ".Desktop") {
							if (Platform.IsWindows) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj));
							} else if (Platform.IsLinux) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj));
							} else if (Platform.IsMac) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj));
							}
						}

						if (project.Name == newProjectName + ".Gtk2") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
							if (Platform.IsWindows) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj));
							} else if (Platform.IsMac) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj));
							}
						}

						if (project.Name == newProjectName + ".Wpf") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj));
						}

						if (project.Name == newProjectName + ".Gtk3") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj));
						}

						if (project.Name == newProjectName + ".Mac") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_mac_proj));
						}

						if (project.Name == newProjectName + ".XamMac") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj));
						}
					}
					monitor.Step (1);
				}

				monitor.EndTask ();
				monitor.EndTask ();
				monitor.ReportSuccess ("Xwt Repository initialized successfully");

				await IdeApp.Workspace.SaveAsync (monitor);
			} catch (Exception e) {
				string msg = GettextCatalog.GetString ("Adding Xwt reference failed: ");
				monitor.ReportError (msg, e);
				MessageService.ShowError (msg, e);
			} finally {
				monitor.Dispose ();
			}
		}
		void BuildDone (ProgressMonitor monitor, BuildResult result, IBuildTarget entry, ITimeTracker tt)
		{
			TaskListEntry[] tasks = null;
			tt.Trace ("Begin reporting build result");
			try {
				if (result != null) {
					lastResult = result;
					monitor.Log.WriteLine ();
					monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------"));
					
					tt.Trace ("Updating task service");
					tasks = new TaskListEntry [result.Errors.Count];
					for (int n=0; n<tasks.Length; n++) {
						tasks [n] = new TaskListEntry (result.Errors [n]);
						tasks [n].Owner = this;
					}

					TaskService.Errors.AddRange (tasks);
					TaskService.Errors.ResetLocationList ();
					IdeApp.Workbench.ActiveLocationList = TaskService.Errors;
					
					tt.Trace ("Reporting result");
					
					string errorString = GettextCatalog.GetPluralString("{0} error", "{0} errors", result.ErrorCount, result.ErrorCount);
					string warningString = GettextCatalog.GetPluralString("{0} warning", "{0} warnings", result.WarningCount, result.WarningCount);

					if (monitor.CancellationToken.IsCancellationRequested) {
						monitor.ReportError (GettextCatalog.GetString ("Build canceled."), null);
					} else if (result.ErrorCount == 0 && result.WarningCount == 0 && lastResult.FailedBuildCount == 0) {
						monitor.ReportSuccess (GettextCatalog.GetString ("Build successful."));
					} else if (result.ErrorCount == 0 && result.WarningCount > 0) {
						monitor.ReportWarning(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString);
					} else if (result.ErrorCount > 0) {
						monitor.ReportError(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString, null);
					} else {
						monitor.ReportError(GettextCatalog.GetString("Build failed."), null);
					}
					tt.Trace ("End build event");
					OnEndBuild (monitor, lastResult.FailedBuildCount == 0, lastResult, entry as SolutionFolderItem);
				} else {
					tt.Trace ("End build event");
					OnEndBuild (monitor, false);
				}
				
				tt.Trace ("Showing results pad");
				
				try {
					Pad errorsPad = IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ErrorListPad> ();
					switch (IdeApp.Preferences.ShowErrorPadAfterBuild.Value) {
					case BuildResultStates.Always:
						if (!errorsPad.Visible)
							errorsPad.IsOpenedAutomatically = true;
						errorsPad.Visible = true;
						errorsPad.BringToFront ();
						break;
					case BuildResultStates.Never:
						break;
					case BuildResultStates.OnErrors:
						if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error))
							goto case BuildResultStates.Always;
						goto case BuildResultStates.Never;
					case BuildResultStates.OnErrorsOrWarnings:
						if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning))
							goto case BuildResultStates.Always;
						goto case BuildResultStates.Never;
					}
				} catch {}
				
				if (tasks != null) {
					TaskListEntry jumpTask = null;
					switch (IdeApp.Preferences.JumpToFirstErrorOrWarning.Value) {
					case JumpToFirst.Error:
						jumpTask = tasks.FirstOrDefault (t => t.Severity == TaskSeverity.Error && TaskStore.IsProjectTaskFile (t));
						break;
					case JumpToFirst.ErrorOrWarning:
						jumpTask = tasks.FirstOrDefault (t => (t.Severity == TaskSeverity.Error || t.Severity == TaskSeverity.Warning) && TaskStore.IsProjectTaskFile (t));
						break;
					}
					if (jumpTask != null) {
						tt.Trace ("Jumping to first result position");
						jumpTask.JumpToPosition ();
					}
				}
				
			} finally {
				monitor.Dispose ();
				tt.End ();
			}
		}
		public bool Deploy ( DeployContext ctx, Solution solution, string defaultConf, string targetDir, bool generateFiles, ProgressMonitor monitor  )
		{
			if (generateFiles) {
				if ( !GenerateFiles ( ctx, solution, defaultConf, monitor ) ) 
					return false;
			}
			
			monitor.BeginTask ( GettextCatalog.GetString( "Deploying Solution to Tarball" ) , 3 );
			try
			{
				string baseDir = Path.GetDirectoryName ( solution.FileName);
	
				ProcessWrapper ag_process = Runtime.ProcessService.StartProcess ( "sh", 
						generateAutotools ? "autogen.sh" : "configure",
						baseDir, 
						monitor.Log, 
						monitor.Log, 
						null );
				ag_process.WaitForOutput ();
				
				if ( ag_process.ExitCode > 0 )
					throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0}'", generateAutotools ? "autogen.sh" : "configure") );
				
				monitor.Step ( 1 );

				using (var sw = new StringWriter ()) {
					using (var chainedOutput = new LogTextWriter ()) {
						chainedOutput.ChainWriter (monitor.Log);
						chainedOutput.ChainWriter (sw);

						using (ProcessWrapper process = Runtime.ProcessService.StartProcess ("make", 
								"dist", 
								baseDir, 
								chainedOutput, 
								monitor.Log, 
							null)) {
							process.WaitForOutput ();

							chainedOutput.UnchainWriter (monitor.Log);
							chainedOutput.UnchainWriter (sw);

							if ( process.ExitCode > 0 )
								throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0}'", "make dist") );
						}

						monitor.Step ( 1 );

						// FIXME: hackish way to get the created tarball's filename
						string output = sw.ToString();
						int targz = output.LastIndexOf  ( "tar.gz" );
						int begin = output.LastIndexOf ( '>', targz );

						string filename = output.Substring ( begin + 1, (targz - begin) + 5 ).Trim ();
						
						FileService.CopyFile (Path.Combine (baseDir, filename), Path.Combine (targetDir, filename));
						monitor.Step ( 1 );
					}
				}
			}
			catch ( Exception e )
			{
				monitor.ReportError ( GettextCatalog.GetString ("Solution could not be deployed: "), e );
				return false;
			}
			finally 
			{
				monitor.EndTask ();
			}
			monitor.ReportSuccess (GettextCatalog.GetString ("Solution was successfully deployed."));
			return true;
		}