diff options
Diffstat (limited to 'main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.Targets')
6 files changed, 47 insertions, 45 deletions
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); |