diff options
Diffstat (limited to 'main/src/addins/Deployment/MonoDevelop.Deployment')
27 files changed, 184 insertions, 191 deletions
diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Commands/Commands.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Commands/Commands.cs index 9096ae8463..01cf8485c4 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Commands/Commands.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Commands/Commands.cs @@ -18,7 +18,7 @@ namespace MonoDevelop.Deployment { protected override void Run () { - SolutionItem entry = IdeApp.ProjectOperations.CurrentSelectedSolutionItem; + SolutionFolderItem entry = IdeApp.ProjectOperations.CurrentSelectedSolutionItem; DeployDialog dlg = new DeployDialog (entry, false); try { if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) { @@ -33,11 +33,11 @@ namespace MonoDevelop.Deployment project.FileName = Path.Combine (dlg.NewProjectSolution.BaseDirectory, project.Name + ".mdse"); project.Packages.Add (p); dlg.NewProjectSolution.Items.Add (project); - IdeApp.ProjectOperations.Save (dlg.NewProjectSolution.ParentSolution); + IdeApp.ProjectOperations.SaveAsync (dlg.NewProjectSolution.ParentSolution); } else { dlg.ExistingPackagingProject.Packages.Add (p); - IdeApp.ProjectOperations.Save (dlg.ExistingPackagingProject); + IdeApp.ProjectOperations.SaveAsync (dlg.ExistingPackagingProject); } } Package pkg = new Package (dlg.PackageBuilder); @@ -63,7 +63,7 @@ namespace MonoDevelop.Deployment try { if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) { project.AddPackage (dlg.NewPackageName, dlg.PackageBuilder); - IdeApp.ProjectOperations.Save (project); + IdeApp.ProjectOperations.SaveAsync (project); } } finally { dlg.Destroy (); @@ -80,7 +80,7 @@ namespace MonoDevelop.Deployment { protected override void Run () { - SolutionItem entry = IdeApp.ProjectOperations.CurrentSelectedSolutionItem; + SolutionFolderItem entry = IdeApp.ProjectOperations.CurrentSelectedSolutionItem; DeployOperations.Install (entry, IdeApp.Workspace.ActiveConfiguration); } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployDialog.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployDialog.cs index 7fa3039562..4fbe017f7b 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployDialog.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployDialog.cs @@ -7,6 +7,7 @@ using MonoDevelop.Projects; using MonoDevelop.Core; using MonoDevelop.Ide; using MonoDevelop.Components; +using System.Linq; namespace MonoDevelop.Deployment.Gui { @@ -16,11 +17,11 @@ namespace MonoDevelop.Deployment.Gui List<PackageBuilder> builders = new List<PackageBuilder> (); PackageBuilder currentBuilder; Gtk.Widget currentEditor; - ReadOnlyCollection<SolutionFolder> combineList; - ReadOnlyCollection<PackagingProject> projectsList; - SolutionItem defaultEntry; + List<SolutionFolder> combineList; + List<PackagingProject> projectsList; + SolutionFolderItem defaultEntry; - public DeployDialog (SolutionItem defaultEntry, bool createBuilderOnly) + public DeployDialog (SolutionFolderItem defaultEntry, bool createBuilderOnly) { this.Build(); notebook.ShowTabs = false; @@ -104,7 +105,7 @@ namespace MonoDevelop.Deployment.Gui { // Fill the combine list int n=0, sel=-1; - combineList = IdeApp.ProjectOperations.CurrentSelectedSolution.GetAllSolutionItems<SolutionFolder> (); + combineList = IdeApp.ProjectOperations.CurrentSelectedSolution.GetAllItems<SolutionFolder> ().ToList (); foreach (SolutionFolder c in combineList) { string name = c.Name; SolutionFolder co = c; @@ -121,7 +122,7 @@ namespace MonoDevelop.Deployment.Gui comboCreateProject.Active = 0; // Fill the packaging project list - projectsList = IdeApp.ProjectOperations.CurrentSelectedSolution.GetAllSolutionItems<PackagingProject> (); + projectsList = IdeApp.ProjectOperations.CurrentSelectedSolution.GetAllItems<PackagingProject> ().ToList(); if (projectsList.Count == 0) { radioAddProject.Sensitive = false; } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployOperations.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployOperations.cs index 1f877eef1d..74fab9ef93 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployOperations.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/DeployOperations.cs @@ -3,14 +3,15 @@ using System.Collections; using MonoDevelop.Core; using MonoDevelop.Ide; using MonoDevelop.Projects; +using System.Threading.Tasks; namespace MonoDevelop.Deployment.Gui { public static class DeployOperations { - public static void Install (SolutionItem entry, ConfigurationSelector configuration) + public static void Install (SolutionFolderItem entry, ConfigurationSelector configuration) { - using (IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor ()) { + using (ProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor ()) { InstallDialog dlg = new InstallDialog (entry); try { if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) @@ -21,36 +22,29 @@ namespace MonoDevelop.Deployment.Gui } } - public static IAsyncOperation BuildPackages (PackagingProject project) + public static Task BuildPackages (PackagingProject project) { return BuildPackages (project.Packages); } - static IAsyncOperation BuildPackages (ICollection packages) + static async Task BuildPackages (ICollection packages) { - IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (true); + ProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (true); // Run the deploy command in a background thread to avoid // deadlocks with the gui thread - System.Threading.Thread t = new System.Threading.Thread ( - delegate () { - using (mon) { - mon.BeginTask ("Creating packages", packages.Count); - foreach (Package p in packages) { - DeployService.BuildPackage (mon, p); - mon.Step (1); - } - mon.EndTask (); + using (mon) { + mon.BeginTask ("Creating packages", packages.Count); + foreach (Package p in packages) { + await DeployService.BuildPackage (mon, p); + mon.Step (1); } - }); - t.IsBackground = true; - t.Start (); - - return mon.AsyncOperation; + mon.EndTask (); + } } - public static IAsyncOperation BuildPackage (Package package) + public static Task BuildPackage (Package package) { return BuildPackages (new object[] { package }); } @@ -59,7 +53,7 @@ namespace MonoDevelop.Deployment.Gui { EditPackageDialog dlg = new EditPackageDialog (package); if (MessageService.ShowCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) - IdeApp.ProjectOperations.Save (package.ParentProject); + IdeApp.ProjectOperations.SaveAsync (package.ParentProject); } } } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/EditPackageDialog.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/EditPackageDialog.cs index 7c2b81062e..58049d30d0 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/EditPackageDialog.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/EditPackageDialog.cs @@ -54,7 +54,7 @@ namespace MonoDevelop.Deployment.Gui protected virtual void OnEntrySelectorSelectionChanged(object sender, System.EventArgs e) { - SolutionItem ce = entrySelector.GetSelectedEntry (); + SolutionFolderItem ce = entrySelector.GetSelectedEntry (); if (ce != null) target.SetSolutionItem (ce, entrySelector.GetSelectedChildren ()); } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/EntrySelectionTree.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/EntrySelectionTree.cs index d5e531f3b8..662d2da34f 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/EntrySelectionTree.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/EntrySelectionTree.cs @@ -7,6 +7,7 @@ using System.Collections.ObjectModel; using MonoDevelop.Ide; using MonoDevelop.Projects; using MonoDevelop.Components; +using System.Linq; namespace MonoDevelop.Deployment.Gui { @@ -15,7 +16,7 @@ namespace MonoDevelop.Deployment.Gui internal partial class EntrySelectionTree : Gtk.Bin { TreeStore store; - Dictionary<SolutionItem,SolutionItem> selectedEntries = new Dictionary<SolutionItem,SolutionItem> (); + Dictionary<SolutionFolderItem,SolutionFolderItem> selectedEntries = new Dictionary<SolutionFolderItem,SolutionFolderItem> (); PackageBuilder builder; Solution solution; @@ -44,13 +45,13 @@ namespace MonoDevelop.Deployment.Gui tree.AppendColumn (col); } - public void Fill (PackageBuilder builder, SolutionItem selection) + public void Fill (PackageBuilder builder, SolutionFolderItem selection) { store.Clear (); this.builder = builder; if (selection is SolutionFolder) { - foreach (SolutionItem e in ((SolutionFolder)selection).GetAllItems ()) { + foreach (SolutionFolderItem e in ((SolutionFolder)selection).GetAllItems ()) { if (builder.CanBuild (e)) selectedEntries [e] = e; } @@ -64,17 +65,15 @@ namespace MonoDevelop.Deployment.Gui else { solution = IdeApp.ProjectOperations.CurrentSelectedSolution; if (solution == null) { - ReadOnlyCollection<Solution> items = IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem.GetAllSolutions (); - if (items.Count > 0) - solution = items [0]; - else + solution = IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem.GetAllItems<Solution> ().FirstOrDefault(); + if (solution == null) return; } } AddEntry (TreeIter.Zero, solution.RootFolder); } - void AddEntry (TreeIter iter, SolutionItem entry) + void AddEntry (TreeIter iter, SolutionFolderItem entry) { string icon; if (entry.ParentFolder == null) @@ -101,49 +100,49 @@ namespace MonoDevelop.Deployment.Gui tree.ExpandToPath (store.GetPath (iter)); if (entry is SolutionFolder) { - foreach (SolutionItem ce in ((SolutionFolder)entry).Items) { + foreach (SolutionFolderItem ce in ((SolutionFolder)entry).Items) { AddEntry (iter, ce); } } } - public void SetSelection (SolutionItem rootEntry, SolutionItem[] childEntries) + public void SetSelection (SolutionFolderItem rootEntry, SolutionFolderItem[] childEntries) { selectedEntries.Clear (); selectedEntries [rootEntry] = rootEntry; - foreach (SolutionItem e in childEntries) + foreach (SolutionFolderItem e in childEntries) selectedEntries [e] = e; UpdateSelectionChecks (TreeIter.Zero, true); } - public SolutionItem GetSelectedEntry () + public SolutionFolderItem GetSelectedEntry () { return GetCommonSolutionItem (); } - public SolutionItem[] GetSelectedChildren () + public SolutionFolderItem[] GetSelectedChildren () { // The first entry is the root entry - SolutionItem common = GetCommonSolutionItem (); + SolutionFolderItem common = GetCommonSolutionItem (); if (common == null) return null; ArrayList list = new ArrayList (); - foreach (SolutionItem e in selectedEntries.Keys) + foreach (SolutionFolderItem e in selectedEntries.Keys) if (e != common) list.Add (e); - return (SolutionItem[]) list.ToArray (typeof(SolutionItem)); + return (SolutionFolderItem[]) list.ToArray (typeof(SolutionFolderItem)); } void OnToggled (object sender, Gtk.ToggledArgs args) { TreeIter iter; store.GetIterFromString (out iter, args.Path); - SolutionItem ob = (SolutionItem) store.GetValue (iter, 2); + SolutionFolderItem ob = (SolutionFolderItem) store.GetValue (iter, 2); if (selectedEntries.ContainsKey (ob)) { selectedEntries.Remove (ob); store.SetValue (iter, 3, false); if (ob is SolutionFolder) { - foreach (SolutionItem e in ((SolutionFolder)ob).GetAllItems ()) + foreach (SolutionFolderItem e in ((SolutionFolder)ob).GetAllItems ()) selectedEntries.Remove (e); UpdateSelectionChecks (TreeIter.Zero, false); } @@ -151,13 +150,13 @@ namespace MonoDevelop.Deployment.Gui selectedEntries [ob] = ob; store.SetValue (iter, 3, true); if (ob is SolutionFolder) { - foreach (SolutionItem e in ((SolutionFolder)ob).GetAllItems ()) { + foreach (SolutionFolderItem e in ((SolutionFolder)ob).GetAllItems ()) { if (builder.CanBuild (e)) selectedEntries [e] = e; } UpdateSelectionChecks (TreeIter.Zero, false); } - SelectCommonCombine ((SolutionItem)ob); + SelectCommonCombine ((SolutionFolderItem)ob); } if (SelectionChanged != null) SelectionChanged (this, EventArgs.Empty); @@ -174,7 +173,7 @@ namespace MonoDevelop.Deployment.Gui return; } do { - bool sel = selectedEntries.ContainsKey ((SolutionItem) store.GetValue (iter, 2)); + bool sel = selectedEntries.ContainsKey ((SolutionFolderItem) store.GetValue (iter, 2)); store.SetValue (iter, 3, sel); if (sel) tree.ExpandToPath (store.GetPath (iter)); @@ -183,16 +182,16 @@ namespace MonoDevelop.Deployment.Gui while (store.IterNext (ref iter)); } - void SelectCommonCombine (SolutionItem e) + void SelectCommonCombine (SolutionFolderItem e) { - SolutionItem common = GetCommonSolutionItem (); + SolutionFolderItem common = GetCommonSolutionItem (); if (common == null) return; selectedEntries [common] = common; - SolutionItem[] entries = new SolutionItem [selectedEntries.Count]; + SolutionFolderItem[] entries = new SolutionFolderItem [selectedEntries.Count]; selectedEntries.Keys.CopyTo (entries, 0); - foreach (SolutionItem se in entries) { - SolutionItem ce = se; + foreach (SolutionFolderItem se in entries) { + SolutionFolderItem ce = se; while (ce != null && ce != common) { selectedEntries [ce] = ce; ce = ce.ParentFolder; @@ -201,7 +200,7 @@ namespace MonoDevelop.Deployment.Gui UpdateSelectionChecks (TreeIter.Zero, false); } - SolutionItem GetCommonSolutionItem () + SolutionFolderItem GetCommonSolutionItem () { return PackageBuilder.GetCommonSolutionItem (selectedEntries.Keys); } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/InstallDialog.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/InstallDialog.cs index 921eab2bb2..e82e53a0d9 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/InstallDialog.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/InstallDialog.cs @@ -6,7 +6,7 @@ namespace MonoDevelop.Deployment.Gui { internal partial class InstallDialog : Gtk.Dialog { - public InstallDialog (SolutionItem entry) + public InstallDialog (SolutionFolderItem entry) { this.Build(); nameEntry.Text = entry.Name; diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/PackagingFeature.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/PackagingFeature.cs index d7ae6b1da2..823c8bf602 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/PackagingFeature.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/PackagingFeature.cs @@ -17,7 +17,7 @@ namespace MonoDevelop.Deployment.Gui get { return GettextCatalog.GetString ("Add a Packaging Project to the solution for generating different kinds of packages for the new project."); } } - public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionItem entry) + public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, SolutionFolderItem entry) { if (parentCombine == null) return FeatureSupportLevel.NotSupported; @@ -30,17 +30,17 @@ namespace MonoDevelop.Deployment.Gui return FeatureSupportLevel.NotSupported; } - public Widget CreateFeatureEditor (SolutionFolder parentCombine, SolutionItem entry) + public Widget CreateFeatureEditor (SolutionFolder parentCombine, SolutionFolderItem entry) { return new PackagingFeatureWidget (parentCombine, entry); } - public void ApplyFeature (SolutionFolder parentCombine, SolutionItem entry, Widget editor) + public void ApplyFeature (SolutionFolder parentCombine, SolutionFolderItem entry, Widget editor) { ((PackagingFeatureWidget)editor).ApplyFeature (); } - public string Validate (SolutionFolder parentCombine, SolutionItem entry, Gtk.Widget editor) + public string Validate (SolutionFolder parentCombine, SolutionFolderItem entry, Gtk.Widget editor) { return null; } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/PackagingFeatureWidget.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/PackagingFeatureWidget.cs index 75a45746c2..9f3b43045b 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/PackagingFeatureWidget.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Gui/PackagingFeatureWidget.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Collections.ObjectModel; using MonoDevelop.Core; using MonoDevelop.Projects; +using System.Linq; namespace MonoDevelop.Deployment.Gui { @@ -11,22 +12,22 @@ namespace MonoDevelop.Deployment.Gui [System.ComponentModel.ToolboxItem(true)] internal partial class PackagingFeatureWidget : Gtk.Bin { - SolutionItem entry; + SolutionFolderItem entry; SolutionFolder parentFolder; ArrayList packages = new ArrayList (); PackagingProject newPackProject; bool creatingPackProject; - public PackagingFeatureWidget (SolutionFolder parentFolder, SolutionItem entry) + public PackagingFeatureWidget (SolutionFolder parentFolder, SolutionFolderItem entry) { this.Build(); this.entry = entry; this.parentFolder = parentFolder; - + creatingPackProject = entry is PackagingProject; if (!creatingPackProject) { - ReadOnlyCollection<PackagingProject> packProjects = parentFolder.ParentSolution.GetAllSolutionItems<PackagingProject> (); + var packProjects = parentFolder.ParentSolution.GetAllItems<PackagingProject> ().ToList (); newPackProject = new PackagingProject (); string label = GettextCatalog.GetString ("Create packages for this project in a new Packaging Project"); @@ -146,12 +147,12 @@ namespace MonoDevelop.Deployment.Gui if (creatingPackProject) { pb.SetSolutionItem (parentFolder.ParentSolution.RootFolder); // Add all compatible projects - foreach (SolutionItem e in parentFolder.ParentSolution.GetAllSolutionItems ()) { + foreach (SolutionFolderItem e in parentFolder.ParentSolution.GetAllSolutionItems ()) { if (pb.CanBuild (e)) pb.AddEntry (e); } } else { - pb.SetSolutionItem (parentFolder, new SolutionItem [] { entry }); + pb.SetSolutionItem (parentFolder, new SolutionFolderItem [] { entry }); } PackageBuilder[] defp = pb.CreateDefaultBuilders (); diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.NodeBuilders/PackageNodeBuilder.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.NodeBuilders/PackageNodeBuilder.cs index 9ac26fb2c2..f721dfc27e 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.NodeBuilders/PackageNodeBuilder.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.NodeBuilders/PackageNodeBuilder.cs @@ -123,7 +123,7 @@ namespace MonoDevelop.Deployment.NodeBuilders Package package = CurrentNode.DataItem as Package; if (MessageService.AskQuestion (GettextCatalog.GetString ("Are you sure you want to delete the package '{0}'?", package.Name), AlertButton.Cancel, AlertButton.Delete) == AlertButton.Delete) { package.ParentProject.Packages.Remove (package); - IdeApp.ProjectOperations.Save (package.ParentProject); + IdeApp.ProjectOperations.SaveAsync (package.ParentProject); } } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/BaseFuseFileCopyHandler.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/BaseFuseFileCopyHandler.cs index b93a173858..dfaca87060 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/BaseFuseFileCopyHandler.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/BaseFuseFileCopyHandler.cs @@ -44,7 +44,7 @@ namespace MonoDevelop.Deployment.Targets get { throw new NotImplementedException ("Inheriting classes must override this."); } } - public override void CopyFiles (IProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection deployFiles, DeployContext context) + public override void CopyFiles (ProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection deployFiles, DeployContext context) { DirectoryInfo tempDir = null; try { @@ -93,9 +93,9 @@ namespace MonoDevelop.Deployment.Targets tempDir.Delete (); } - public abstract void MountTempDirectory (IProgressMonitor monitor, FileCopyConfiguration copyConfig, string tempPath); + public abstract void MountTempDirectory (ProgressMonitor monitor, FileCopyConfiguration copyConfig, string tempPath); - protected void RunFuseCommand (IProgressMonitor monitor, string command, string args) + protected void RunFuseCommand (ProgressMonitor monitor, string command, string args) { LoggingService.LogInfo ("Running FUSE command: {0} {1}", command, args); var log = new StringWriter (); @@ -104,13 +104,12 @@ namespace MonoDevelop.Deployment.Targets RedirectStandardOutput = true, UseShellExecute = false, }; - using (var opMon = new AggregatedOperationMonitor (monitor)) { - using (var pWrapper = MonoDevelop.Core.Runtime.ProcessService.StartProcess (psi, log, log, null)) { - opMon.AddOperation (pWrapper); - pWrapper.WaitForOutput (); - if (pWrapper.ExitCode != 0) - throw new Exception (log.ToString ()); - } + + using (var pWrapper = Runtime.ProcessService.StartProcess (psi, log, log, null)) + using (monitor.CancellationToken.Register (pWrapper.Cancel)) { + pWrapper.WaitForOutput (); + if (pWrapper.ExitCode != 0) + throw new Exception (log.ToString ()); } } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/BinariesZipPackageBuilder.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/BinariesZipPackageBuilder.cs index b663c990b9..2149ea019b 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/BinariesZipPackageBuilder.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/BinariesZipPackageBuilder.cs @@ -39,7 +39,7 @@ namespace MonoDevelop.Deployment.Targets get { return "Archive of Binaries"; } } - public override void InitializeSettings (SolutionItem entry) + public override void InitializeSettings (SolutionFolderItem entry) { targetFile = Path.Combine (entry.BaseDirectory, entry.Name) + ".tar.gz"; if (entry.ParentSolution != null) @@ -51,7 +51,7 @@ namespace MonoDevelop.Deployment.Targets return configuration != null ? new string [] { configuration } : new string [0]; } - public override bool CanBuild (SolutionItem entry) + public override bool CanBuild (SolutionFolderItem entry) { // Can build anything but PackagingProject return !(entry is PackagingProject); @@ -62,18 +62,21 @@ namespace MonoDevelop.Deployment.Targets return new DeployContext (this, platform, null); } - protected override bool OnBuild (IProgressMonitor monitor, DeployContext ctx) + protected override bool OnBuild (ProgressMonitor monitor, DeployContext ctx) { string tmpFolder = null; - + try { SolutionConfigurationSelector conf = (SolutionConfigurationSelector) configuration; - BuildResult res = RootSolutionItem.Build (monitor, conf); - if (res.ErrorCount > 0) { - foreach (BuildError e in res.Errors) - monitor.ReportError (e.ToString (), null); - monitor.ReportError (GettextCatalog.GetString ("The source project failed to build."), null); - return false; + var bt = RootSolutionItem as IBuildTarget; + if (bt != null) { + BuildResult res = bt.Build (monitor, conf).Result; + if (res.ErrorCount > 0) { + foreach (BuildError e in res.Errors) + monitor.ReportError (e.ToString (), null); + monitor.ReportError (GettextCatalog.GetString ("The source project failed to build."), null); + return false; + } } tmpFolder = FileService.CreateTempDirectory (); @@ -107,8 +110,7 @@ namespace MonoDevelop.Deployment.Targets if (tmpFolder != null) Directory.Delete (tmpFolder, true); } - if (monitor.AsyncOperation.Success) - monitor.Log.WriteLine (GettextCatalog.GetString ("Created file: {0}", targetFile)); + monitor.Log.WriteLine (GettextCatalog.GetString ("Created file: {0}", targetFile)); return true; } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/CommandPackageBuilder.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/CommandPackageBuilder.cs index 353331931a..a3d2a975c0 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/CommandPackageBuilder.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/CommandPackageBuilder.cs @@ -33,6 +33,7 @@ using MonoDevelop.Projects; using MonoDevelop.Core.Serialization; using MonoDevelop.Core; using MonoDevelop.Core.Execution; +using System.Threading; namespace MonoDevelop.Deployment.Targets { @@ -88,7 +89,7 @@ namespace MonoDevelop.Deployment.Targets } } - protected override bool OnBuild (IProgressMonitor monitor, DeployContext ctx) + protected override bool OnBuild (ProgressMonitor monitor, DeployContext ctx) { string consMsg; IConsole cons; @@ -101,7 +102,7 @@ namespace MonoDevelop.Deployment.Targets } monitor.Log.WriteLine (GettextCatalog.GetString ("Executing: {0} {1} {2}", Command, Arguments, consMsg)); - IProcessAsyncOperation process = Runtime.ProcessService.StartConsoleProcess (Command, Arguments, workingDirectory, cons, null); + ProcessAsyncOperation process = Runtime.ProcessService.StartConsoleProcess (Command, Arguments, workingDirectory, cons, null); process.WaitForCompleted (); @@ -115,20 +116,21 @@ namespace MonoDevelop.Deployment.Targets class MonitorConsole: IConsole { StringReader nullReader; - IProgressMonitor monitor; + ProgressMonitor monitor; + CancellationTokenRegistration tr; - public MonitorConsole (IProgressMonitor monitor) + public MonitorConsole (ProgressMonitor monitor) { this.monitor = monitor; - monitor.CancelRequested += OnCancel; + tr = monitor.CancellationToken.Register (OnCancel); } public void Dispose () { - monitor.CancelRequested -= OnCancel; + tr.Dispose (); } - void OnCancel (IProgressMonitor monitor) + void OnCancel () { if (CancelRequested != null) CancelRequested (this, EventArgs.Empty); diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/LocalFileCopyHandler.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/LocalFileCopyHandler.cs index f961d05edf..e143d62d39 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/LocalFileCopyHandler.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/LocalFileCopyHandler.cs @@ -51,12 +51,12 @@ namespace MonoDevelop.Deployment.Targets return new LocalFileCopyConfiguration (); } - public virtual void CopyFiles (IProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection deployFiles, DeployContext context) + public virtual void CopyFiles (ProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection deployFiles, DeployContext context) { InternalCopyFiles (monitor, replacePolicy, copyConfig, deployFiles, context, null); } - internal void InternalCopyFiles (IProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection deployFiles, DeployContext context, string realPrefix) + internal void InternalCopyFiles (ProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection deployFiles, DeployContext context, string realPrefix) { string targetDirectory = ((LocalFileCopyConfiguration) copyConfig).TargetDirectory; @@ -111,7 +111,7 @@ namespace MonoDevelop.Deployment.Targets long carry = 0; monitor.BeginTask (copyConfig.FriendlyLocation, progressBarLength); CopyReportCallback copyCallback = delegate (long bytes) { - if (monitor.IsCancelRequested) + if (monitor.CancellationToken.IsCancellationRequested) return false; int steps = (int) (bytes / stepSize); carry += bytes % stepSize; @@ -127,7 +127,7 @@ namespace MonoDevelop.Deployment.Targets //now the actual copy foreach (DeployFileConf file in files) { //abort the copy if cancelling - if (monitor.IsCancelRequested) + if (monitor.CancellationToken.IsCancellationRequested) break; EnsureDirectoryExists (Path.GetDirectoryName (file.InternalTargetFile)); diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/SourcesZipPackageBuilder.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/SourcesZipPackageBuilder.cs index 83c06ffc2d..6820ae2d8f 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/SourcesZipPackageBuilder.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/SourcesZipPackageBuilder.cs @@ -24,9 +24,9 @@ namespace MonoDevelop.Deployment.Targets get { return "Archive of Sources"; } } - public override bool CanBuild (SolutionItem entry) + public override bool CanBuild (SolutionFolderItem entry) { - return entry is SolutionFolder || entry is SolutionEntityItem; + return entry is SolutionFolder || entry is SolutionItem; } @@ -58,14 +58,14 @@ namespace MonoDevelop.Deployment.Targets set { targetFile = value; } } - protected override bool OnBuild (IProgressMonitor monitor, DeployContext ctx) + protected override bool OnBuild (ProgressMonitor monitor, DeployContext ctx) { string sourceFile; - SolutionItem entry = RootSolutionItem; + SolutionFolderItem entry = RootSolutionItem; if (entry is SolutionFolder) sourceFile = entry.ParentSolution.FileName; else - sourceFile = ((SolutionEntityItem)entry).FileName; + sourceFile = ((SolutionItem)entry).FileName; AggregatedProgressMonitor mon = new AggregatedProgressMonitor (); mon.AddSlaveMonitor (monitor, MonitorAction.WriteLog|MonitorAction.ReportError|MonitorAction.ReportWarning|MonitorAction.ReportSuccess); @@ -81,13 +81,13 @@ namespace MonoDevelop.Deployment.Targets // Export the project - SolutionItem[] ents = GetChildEntries (); + SolutionFolderItem[] ents = GetChildEntries (); string[] epaths = new string [ents.Length]; for (int n=0; n<ents.Length; n++) epaths [n] = ents [n].ItemId; - Services.ProjectService.Export (mon, sourceFile, epaths, folder, FileFormat); - if (!mon.AsyncOperation.Success) + var r = Services.ProjectService.Export (mon, sourceFile, epaths, folder, FileFormat).Result; + if (string.IsNullOrEmpty (r)) return false; // Create the archive @@ -99,12 +99,11 @@ namespace MonoDevelop.Deployment.Targets finally { Directory.Delete (tmpFolder, true); } - if (monitor.AsyncOperation.Success) - monitor.Log.WriteLine (GettextCatalog.GetString ("Created file: {0}", targetFile)); + monitor.Log.WriteLine (GettextCatalog.GetString ("Created file: {0}", targetFile)); return true; } - public override void InitializeSettings (SolutionItem entry) + public override void InitializeSettings (SolutionFolderItem entry) { targetFile = Path.Combine (entry.BaseDirectory, entry.Name) + ".tar.gz"; if (entry.ParentSolution != null) diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/SshFuseFileCopyHandler.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/SshFuseFileCopyHandler.cs index fef148d5c1..4029434912 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/SshFuseFileCopyHandler.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets/SshFuseFileCopyHandler.cs @@ -42,7 +42,7 @@ namespace MonoDevelop.Deployment.Targets get { return "SSH (FUSE)"; } } - public override void MountTempDirectory (IProgressMonitor monitor, FileCopyConfiguration copyConfig, string tempPath) + public override void MountTempDirectory (ProgressMonitor monitor, FileCopyConfiguration copyConfig, string tempPath) { SshFuseFileCopyConfiguration config = (SshFuseFileCopyConfiguration) copyConfig; string fuseArgs = string.Format ("{0} {1} {2}", config.TargetDirectory, tempPath, config.ExtraMountArguments); diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DefaultDeployServiceExtension.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DefaultDeployServiceExtension.cs index 52715746d0..3b6554e7be 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DefaultDeployServiceExtension.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DefaultDeployServiceExtension.cs @@ -8,7 +8,7 @@ namespace MonoDevelop.Deployment { class DefaultDeployServiceExtension: DeployServiceExtension { - public override DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionItem entry, ConfigurationSelector configuration) + public override DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration) { if (entry is IDeployable) return new DeployFileCollection (((IDeployable)entry).GetDeployFiles (configuration)); diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployFile.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployFile.cs index b8287104a5..e03eb8b89d 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployFile.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployFile.cs @@ -44,7 +44,7 @@ namespace MonoDevelop.Deployment string targetDirectoryID; DeployContext deployContext; bool isTemplate; - SolutionItem sourceSolutionItem; + SolutionFolderItem sourceSolutionItem; string displayName; DeployFileAttributes attributes; @@ -60,12 +60,12 @@ namespace MonoDevelop.Deployment sourceSolutionItem = pfile.Project; }
- public DeployFile (SolutionItem sourceSolutionItem, FilePath sourcePath, FilePath relativeTargetPath) + public DeployFile (SolutionFolderItem sourceSolutionItem, FilePath sourcePath, FilePath relativeTargetPath) : this (sourceSolutionItem, sourcePath, relativeTargetPath, TargetDirectory.ProgramFiles) { }
- public DeployFile (SolutionItem sourceSolutionItem, FilePath sourcePath, FilePath relativeTargetPath, string targetDirectoryID) + public DeployFile (SolutionFolderItem sourceSolutionItem, FilePath sourcePath, FilePath relativeTargetPath, string targetDirectoryID) { this.targetDirectoryID = targetDirectoryID; this.sourcePath = sourcePath; @@ -78,7 +78,7 @@ namespace MonoDevelop.Deployment this.deployContext = deployContext; } - public SolutionItem SourceSolutionItem { + public SolutionFolderItem SourceSolutionItem { get { return sourceSolutionItem; } } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployService.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployService.cs index b6f9695245..51fbdf8329 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployService.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployService.cs @@ -48,6 +48,7 @@ using ICSharpCode.SharpZipLib.Zip; using System.Reflection;
using Mono.Unix.Native;
using Mono.Unix; +using System.Threading.Tasks; namespace MonoDevelop.Deployment { @@ -90,7 +91,7 @@ namespace MonoDevelop.Deployment return props; } - public static PackageBuilder[] GetSupportedPackageBuilders (SolutionItem entry) + public static PackageBuilder[] GetSupportedPackageBuilders (SolutionFolderItem entry) { object[] builders = AddinManager.GetExtensionObjects ("/MonoDevelop/DeployService/PackageBuilders", false); ArrayList list = new ArrayList (); @@ -110,13 +111,13 @@ namespace MonoDevelop.Deployment return (PackageBuilder[]) AddinManager.GetExtensionObjects ("/MonoDevelop/DeployService/PackageBuilders", typeof(PackageBuilder), false); } - public static void Install (IProgressMonitor monitor, SolutionItem entry, string prefix, string appName, ConfigurationSelector configuration) + public static void Install (ProgressMonitor monitor, SolutionFolderItem entry, string prefix, string appName, ConfigurationSelector configuration) { InstallResolver res = new InstallResolver (); res.Install (monitor, entry, appName, prefix, configuration); } - public static void CreateArchive (IProgressMonitor mon, string folder, string targetFile) + public static void CreateArchive (ProgressMonitor mon, string folder, string targetFile) { string tf = Path.GetFileNameWithoutExtension (targetFile); if (tf.EndsWith (".tar")) tf = Path.GetFileNameWithoutExtension (tf); @@ -235,27 +236,29 @@ namespace MonoDevelop.Deployment return null; } - public static bool BuildPackage (IProgressMonitor mon, Package package) + public static Task<bool> BuildPackage (ProgressMonitor mon, Package package) { return BuildPackage (mon, package.PackageBuilder); } - public static bool BuildPackage (IProgressMonitor mon, PackageBuilder builder) + public static Task<bool> BuildPackage (ProgressMonitor mon, PackageBuilder builder) { - DeployServiceExtension extensionChain = GetExtensionChain (); - return extensionChain.BuildPackage (mon, builder); + return Task<bool>.Factory.StartNew (delegate { + DeployServiceExtension extensionChain = GetExtensionChain (); + return extensionChain.BuildPackage (mon, builder); + }); } - public static DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionItem[] entries, ConfigurationSelector configuration) + public static DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionFolderItem[] entries, ConfigurationSelector configuration) { DeployFileCollection col = new DeployFileCollection (); - foreach (SolutionItem e in entries) { + foreach (SolutionFolderItem e in entries) { col.AddRange (GetDeployFiles (ctx, e, configuration)); } return col; } - public static DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionItem entry, ConfigurationSelector configuration) + public static DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration) { ArrayList todel = new ArrayList (); diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployServiceExtension.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployServiceExtension.cs index ef9335b420..4359230f6b 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployServiceExtension.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/DeployServiceExtension.cs @@ -9,7 +9,7 @@ namespace MonoDevelop.Deployment { internal DeployServiceExtension Next; - public virtual bool BuildPackage (IProgressMonitor monitor, PackageBuilder builder) + public virtual bool BuildPackage (ProgressMonitor monitor, PackageBuilder builder) { if (Next != null) return Next.BuildPackage (monitor, builder); @@ -17,7 +17,7 @@ namespace MonoDevelop.Deployment return builder.Build (monitor); } - public virtual DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionItem entry, ConfigurationSelector configuration) + public virtual DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration) { if (entry is SolutionFolder) return GetCombineDeployFiles (ctx, (SolutionFolder) entry, configuration); diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/FileCopyConfiguration.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/FileCopyConfiguration.cs index 0149d1040d..53c916d787 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/FileCopyConfiguration.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/FileCopyConfiguration.cs @@ -69,7 +69,7 @@ namespace MonoDevelop.Deployment get; } - public void CopyFiles (IProgressMonitor monitor, IFileReplacePolicy replacePolicy, DeployFileCollection files, DeployContext context) + public void CopyFiles (ProgressMonitor monitor, IFileReplacePolicy replacePolicy, DeployFileCollection files, DeployContext context) { Handler.CopyFiles (monitor, replacePolicy, this, files, context); } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/FileCopyHandler.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/FileCopyHandler.cs index 38108b7ded..7b1f3c2f00 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/FileCopyHandler.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/FileCopyHandler.cs @@ -59,7 +59,7 @@ namespace MonoDevelop.Deployment return c; } - internal void CopyFiles (IProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection files, DeployContext context) + internal void CopyFiles (ProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection files, DeployContext context) { handler.CopyFiles (monitor, replacePolicy, copyConfig, files, context); } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/IFileCopyHandler.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/IFileCopyHandler.cs index 58f41c36c7..1aabddc49e 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/IFileCopyHandler.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/IFileCopyHandler.cs @@ -40,6 +40,6 @@ namespace MonoDevelop.Deployment string Id { get; } string Name { get; } FileCopyConfiguration CreateConfiguration (); - void CopyFiles (IProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection files, DeployContext context); + void CopyFiles (ProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection files, DeployContext context); } } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/InstallResolver.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/InstallResolver.cs index 50e1ca8951..778eb928ee 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/InstallResolver.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/InstallResolver.cs @@ -40,7 +40,7 @@ namespace MonoDevelop.Deployment { string appName; - public void Install (IProgressMonitor monitor, SolutionItem entry, string appName, string prefix, ConfigurationSelector configuration) + public void Install (ProgressMonitor monitor, SolutionFolderItem entry, string appName, string prefix, ConfigurationSelector configuration) { this.appName = appName; @@ -49,9 +49,9 @@ namespace MonoDevelop.Deployment } } - void InstallEntry (IProgressMonitor monitor, DeployContext ctx, SolutionItem entry, ConfigurationSelector configuration) + void InstallEntry (ProgressMonitor monitor, DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration) { - foreach (DeployFile df in DeployService.GetDeployFiles (ctx, new SolutionItem[] { entry }, configuration)) { + foreach (DeployFile df in DeployService.GetDeployFiles (ctx, new SolutionFolderItem[] { entry }, configuration)) { string targetPath = df.ResolvedTargetFile; if (targetPath == null) { monitor.ReportWarning ("Could not copy file '" + df.RelativeTargetPath + "': Unknown target directory."); @@ -64,7 +64,7 @@ namespace MonoDevelop.Deployment SolutionFolder c = entry as SolutionFolder; if (c != null) { monitor.BeginTask ("Installing solution '" + c.Name + "'", c.Items.Count); - foreach (SolutionItem ce in c.Items) { + foreach (SolutionFolderItem ce in c.Items) { InstallEntry (monitor, ctx, ce, configuration); monitor.Step (1); } @@ -72,7 +72,7 @@ namespace MonoDevelop.Deployment } } - void CopyFile (IProgressMonitor monitor, string src, string dest, DeployFileAttributes atts) + void CopyFile (ProgressMonitor monitor, string src, string dest, DeployFileAttributes atts) { dest = FileService.GetFullPath (dest); monitor.Log.WriteLine (GettextCatalog.GetString ("Deploying file {0}.", dest)); diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/Package.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/Package.cs index 8eeac21c76..22362fda36 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/Package.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/Package.cs @@ -6,6 +6,7 @@ using MonoDevelop.Core; using MonoDevelop.Core.ProgressMonitoring; using MonoDevelop.Projects; using MonoDevelop.Core.Serialization; +using System.Threading.Tasks; namespace MonoDevelop.Deployment { @@ -46,11 +47,11 @@ namespace MonoDevelop.Deployment set { builder = value; NotifyChanged (); } } - public bool Build (IProgressMonitor monitor) + public async Task<bool> Build (ProgressMonitor monitor) { - DeployService.BuildPackage (monitor, this); + var res = await DeployService.BuildPackage (monitor, this); needsBuilding = false; - return true; + return res; } public bool NeedsBuilding { @@ -62,7 +63,7 @@ namespace MonoDevelop.Deployment } } - public void Clean (IProgressMonitor monitor) + public void Clean (ProgressMonitor monitor) { needsBuilding = true; } diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/PackageBuilder.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/PackageBuilder.cs index 3df5f51486..4dfa51c332 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/PackageBuilder.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/PackageBuilder.cs @@ -34,6 +34,7 @@ using MonoDevelop.Core; using MonoDevelop.Core.ProgressMonitoring; using MonoDevelop.Projects; using MonoDevelop.Ide; +using System.Threading.Tasks; namespace MonoDevelop.Deployment { @@ -50,8 +51,8 @@ namespace MonoDevelop.Deployment [ItemProperty ("RootEntry")] SolutionItemReference rootEntry; - List<SolutionItem> childCombineEntries; - SolutionItem rootSolutionItem; + List<SolutionFolderItem> childCombineEntries; + SolutionFolderItem rootSolutionItem; public PackageBuilder () { @@ -76,7 +77,7 @@ namespace MonoDevelop.Deployment return null; } - internal bool Build (IProgressMonitor monitor) + internal bool Build (ProgressMonitor monitor) { monitor.BeginTask ("Package: " + Description, 1); DeployContext ctx = null; @@ -85,13 +86,11 @@ namespace MonoDevelop.Deployment if (ctx != null) ctx.FileFilter = this; if (!OnBuild (monitor, ctx)) { - monitor.AsyncOperation.Cancel (); return false; } } catch (Exception ex) { monitor.ReportError ("Package creation failed", ex); LoggingService.LogError ("Package creation failed", ex); - monitor.AsyncOperation.Cancel (); return false; } finally { monitor.EndTask (); @@ -101,12 +100,12 @@ namespace MonoDevelop.Deployment return true; } - public virtual bool CanBuild (SolutionItem entry) + public virtual bool CanBuild (SolutionFolderItem entry) { return true; } - public virtual void InitializeSettings (SolutionItem entry) + public virtual void InitializeSettings (SolutionFolderItem entry) { } @@ -123,7 +122,7 @@ namespace MonoDevelop.Deployment rootEntry = other.rootEntry; if (other.childCombineEntries != null) - childCombineEntries = new List<SolutionItem> (other.childCombineEntries); + childCombineEntries = new List<SolutionFolderItem> (other.childCombineEntries); else childCombineEntries = null; if (other.excludedFiles != null) @@ -138,7 +137,7 @@ namespace MonoDevelop.Deployment return new PackageBuilder [0]; } - protected virtual bool OnBuild (IProgressMonitor monitor, DeployContext ctx) + protected virtual bool OnBuild (ProgressMonitor monitor, DeployContext ctx) { return true; } @@ -158,15 +157,15 @@ namespace MonoDevelop.Deployment return new DeployContext (this, DeployService.CurrentPlatform, null); } - public void SetSolutionItem (SolutionItem entry) + public void SetSolutionItem (SolutionFolderItem entry) { SetSolutionItem (entry, null); } - public void SetSolutionItem (SolutionItem rootSolutionItem, IEnumerable<SolutionItem> childEntries) + public void SetSolutionItem (SolutionFolderItem rootSolutionItem, IEnumerable<SolutionFolderItem> childEntries) { this.rootSolutionItem = rootSolutionItem; - childCombineEntries = new List<SolutionItem> (); + childCombineEntries = new List<SolutionFolderItem> (); if (childEntries != null) childCombineEntries.AddRange (childEntries); @@ -187,11 +186,11 @@ namespace MonoDevelop.Deployment { this.rootEntry = new SolutionItemReference (rootSolutionItem); this.childEntries.Clear (); - foreach (SolutionItem e in childCombineEntries) + foreach (SolutionFolderItem e in childCombineEntries) childEntries.Add (new SolutionItemReference (e)); } - public SolutionItem RootSolutionItem { + public SolutionFolderItem RootSolutionItem { get { if (rootSolutionItem == null && rootEntry != null) rootSolutionItem = GetEntry (rootEntry); @@ -205,7 +204,7 @@ namespace MonoDevelop.Deployment } } - public void AddEntry (SolutionItem entry) + public void AddEntry (SolutionFolderItem entry) { SolutionItemReference fp = new SolutionItemReference (entry); foreach (SolutionItemReference s in childEntries) @@ -215,7 +214,7 @@ namespace MonoDevelop.Deployment if (rootEntry == fp) return; - List<SolutionItem> list = new List<SolutionItem> (); + List<SolutionFolderItem> list = new List<SolutionFolderItem> (); if (RootSolutionItem != null) list.Add (RootSolutionItem); list.AddRange (GetChildEntries()); @@ -224,8 +223,8 @@ namespace MonoDevelop.Deployment rootSolutionItem = GetCommonSolutionItem (list); list.Remove (rootSolutionItem); - foreach (SolutionItem e in list.ToArray ()) { - SolutionItem ce = e.ParentFolder; + foreach (SolutionFolderItem e in list.ToArray ()) { + SolutionFolderItem ce = e.ParentFolder; while (ce != rootSolutionItem) { if (!list.Contains (ce)) list.Add (ce); @@ -236,36 +235,36 @@ namespace MonoDevelop.Deployment UpdateEntryNames (); } - public SolutionItem[] GetChildEntries () + public SolutionFolderItem[] GetChildEntries () { if (childCombineEntries != null) return childCombineEntries.ToArray (); - childCombineEntries = new List<SolutionItem> (); + childCombineEntries = new List<SolutionFolderItem> (); foreach (SolutionItemReference en in childEntries) { - SolutionItem re = GetEntry (en); + SolutionFolderItem re = GetEntry (en); if (re != null && !(re is UnknownSolutionItem)) childCombineEntries.Add (re); } return childCombineEntries.ToArray (); } - public SolutionItem[] GetAllEntries () + public SolutionFolderItem[] GetAllEntries () { - List<SolutionItem> list = new List<SolutionItem> (); + List<SolutionFolderItem> list = new List<SolutionFolderItem> (); if (RootSolutionItem != null) list.Add (RootSolutionItem); list.AddRange (GetChildEntries ()); return list.ToArray (); } - SolutionItem GetEntry (SolutionItemReference reference) + SolutionFolderItem GetEntry (SolutionItemReference reference) { if (IdeApp.IsInitialized) - return Services.ProjectService.ReadSolutionItem (new NullProgressMonitor (), reference, IdeApp.Workspace.Items.ToArray ()); + return Services.ProjectService.ReadSolutionItem (new ProgressMonitor (), reference, IdeApp.Workspace.Items.ToArray ()).Result; else - return Services.ProjectService.ReadSolutionItem (new NullProgressMonitor (), reference); + return Services.ProjectService.ReadSolutionItem (new ProgressMonitor (), reference).Result; } public virtual DeployFileCollection GetDeployFiles (DeployContext ctx, ConfigurationSelector configuration) @@ -307,10 +306,10 @@ namespace MonoDevelop.Deployment } - internal static SolutionItem GetCommonSolutionItem (IEnumerable<SolutionItem> entries) + internal static SolutionFolderItem GetCommonSolutionItem (IEnumerable<SolutionFolderItem> entries) { - SolutionItem common = null; - foreach (SolutionItem it in entries) { + SolutionFolderItem common = null; + foreach (SolutionFolderItem it in entries) { if (common == null) common = it; else diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/PackagingProject.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/PackagingProject.cs index 184b2dee9f..6641fba97c 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/PackagingProject.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/PackagingProject.cs @@ -5,10 +5,11 @@ using System.Collections.Generic; using MonoDevelop.Core; using MonoDevelop.Projects; using MonoDevelop.Core.Serialization; +using System.Threading.Tasks; namespace MonoDevelop.Deployment { - public class PackagingProject: SolutionEntityItem + public class PackagingProject: SolutionItem { PackageCollection packages; @@ -40,21 +41,19 @@ namespace MonoDevelop.Deployment return conf; } - protected override void OnClean (IProgressMonitor monitor, ConfigurationSelector configuration) + protected override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration) { foreach (Package p in packages) p.Clean (monitor); + return Task.FromResult (BuildResult.Success); } - protected override BuildResult OnBuild (IProgressMonitor monitor, ConfigurationSelector configuration) + protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration) { foreach (Package p in packages) - p.Build (monitor); - return null; - } - - protected override void OnExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) - { + if (!await p.Build (monitor)) + break; + return BuildResult.Success; } protected override bool OnGetNeedsBuilding (ConfigurationSelector configuration) @@ -65,12 +64,6 @@ namespace MonoDevelop.Deployment return false; } - protected override void OnSetNeedsBuilding (bool val, ConfigurationSelector configuration) - { - foreach (Package p in packages) - p.NeedsBuilding = val; - } - internal void NotifyPackagesChanged () { if (PackagesChanged != null) diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/UnknownPackageBuilder.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/UnknownPackageBuilder.cs index 04d3e92770..72b356dc5d 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/UnknownPackageBuilder.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment/UnknownPackageBuilder.cs @@ -54,7 +54,7 @@ namespace MonoDevelop.Deployment } } - protected override bool OnBuild (IProgressMonitor monitor, DeployContext ctx) + protected override bool OnBuild (ProgressMonitor monitor, DeployContext ctx) { monitor.ReportError ("Unknown package type. The package can't be generated.", null); return false; |