public virtual void CopyFrom (OperationContext other) { if (other.customData != null) customData = new Dictionary<object, object> (other.customData); else customData = null; }
protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { foreach (Package p in packages) if (!await p.Build (monitor)) break; return BuildResult.CreateSuccess (); }
public override void CopyFrom (OperationContext other) { base.CopyFrom (other); var o = other as ProjectOperationContext; if (o != null) GlobalProperties = new ProjectItemMetadata ((ProjectItemMetadata) o.GlobalProperties); }
public async Task<BuildResult> Build (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null) { var res = new BuildResult { BuildCount = 0 }; foreach (var bt in Items.OfType<IBuildTarget> ()) res.Append (await bt.Build (monitor, configuration, operationContext:operationContext)); return res; }
public override void CopyFrom (OperationContext other) { base.CopyFrom (other); var o = other as ProjectOperationContext; if (o != null) GlobalProperties = new Dictionary<string,string> (o.GlobalProperties); }
/// <summary> /// If the project is a NuGet packaging project then just use the normal build target. /// This ensures that the dependent projects are built. /// /// Otherwise the Pack target is called. /// </summary> public async Task<BuildResult> Build (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null) { if (project is PackagingProject) { return await project.Build (monitor, configuration, buildReferencedTargets, new TargetEvaluationContext (operationContext)); } else { return await Pack (monitor, configuration, buildReferencedTargets, operationContext); } }
protected override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { Task restoreTask = PackageRestoreTask; if (restoreTask != null) { return WaitForRestoreThenBuild (restoreTask, monitor, configuration, operationContext); } return base.OnBuild (monitor, configuration, operationContext); }
public override void CopyFrom (OperationContext other) { base.CopyFrom (other); var o = other as TargetEvaluationContext; if (o != null) { PropertiesToEvaluate = new HashSet<string> (o.PropertiesToEvaluate); o.ItemsToEvaluate = new HashSet<string> (o.ItemsToEvaluate); } }
protected override IEnumerable<SolutionItemRunConfiguration> OnGetRunConfigurations (OperationContext ctx) { var configs = base.OnGetRunConfigurations (ctx); // If the project has unit tests, add a configuration for running the tests if (FindRootTest () != null) configs = configs.Concat (unitTestingRunConfigurationInstance); return configs; }
async Task<BuildResult> WaitForRestoreThenBuild (Task restoreTask, ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { try { await restoreTask; } catch (Exception ex) { var result = new BuildResult (); result.AddError (GettextCatalog.GetString ("{0}. Please see the Package Console for more details.", ex.Message)); return result; } return await base.OnBuild (monitor, configuration, operationContext); }
async Task<BuildResult> Pack (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets, OperationContext operationContext) { var result = new BuildResult (); // Build the project and any dependencies first. if (buildReferencedTargets && project.GetReferencedItems (configuration).Any ()) { result = await project.Build (monitor, configuration, buildReferencedTargets, operationContext); if (result.Failed) return result; } // Generate the NuGet package by calling the Pack target. var packResult = (await project.RunTarget (monitor, "Pack", configuration, new TargetEvaluationContext (operationContext))).BuildResult; return result.Append (packResult); }
protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { if (Project.References.Count == 0 || !GtkDesignInfo.HasDesignedObjects (Project)) return await base.OnBuild (monitor, configuration, operationContext); Generator gen = new Generator (); if (!await gen.Run (monitor, Project, configuration)) { BuildResult gr = new BuildResult (); foreach (string s in gen.Messages) gr.AddError (DesignInfo.GuiBuilderProject.File, 0, 0, null, s); return gr; } BuildResult res = await base.OnBuild (monitor, configuration, operationContext); if (gen.Messages != null) { foreach (string s in gen.Messages) res.AddWarning (DesignInfo.GuiBuilderProject.File, 0, 0, null, s); if (gen.Messages.Length > 0) DesignInfo.ForceCodeGenerationOnBuild (); } if (res.Failed && !Platform.IsWindows && !Platform.IsMac) { // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel if (Project.AssemblyContext.GetPackage ("gtk-sharp-2.0") == null) { string msg = GettextCatalog.GetString ( "ERROR: MonoDevelop could not find the Gtk# 2.0 development package. " + "Compilation of projects depending on Gtk# libraries will fail. " + "You may need to install development packages for gtk-sharp-2.0."); monitor.Log.WriteLine (); monitor.Log.WriteLine (BrandingService.BrandApplicationName (msg)); } } return res; }
public TargetEvaluationContext (OperationContext other): this () { if (other != null) CopyFrom (other); }
protected override Task <BuildResult> OnBuild(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { return(Task.FromResult(BuildResult.CreateSuccess())); }
async Task<BuildResult> BuildSolutionItemAsync (IBuildTarget entry, ProgressMonitor monitor, ITimeTracker tt, bool skipPrebuildCheck = false, OperationContext operationContext = null) { BuildResult result = null; try { if (!skipPrebuildCheck) { tt.Trace ("Pre-build operations"); result = DoBeforeCompileAction (); } //wait for any custom tools that were triggered by the save, since the build may depend on them await MonoDevelop.Ide.CustomTools.CustomToolService.WaitForRunningTools (monitor); if (skipPrebuildCheck || result.ErrorCount == 0) { tt.Trace ("Building item"); result = await entry.Build (monitor, IdeApp.Workspace.ActiveConfiguration, true, operationContext); } } catch (Exception ex) { monitor.ReportError (GettextCatalog.GetString ("Build failed."), ex); if (result == null) result = new BuildResult (); result.AddError ("Build failed. See the build log for details."); if (result.SourceTarget == null) result.SourceTarget = entry; } finally { tt.Trace ("Done building"); } BuildDone (monitor, result, entry, tt); // BuildDone disposes the monitor return result; }
public AsyncOperation<BuildResult> Build (IBuildTarget entry, CancellationToken? cancellationToken = null, OperationContext operationContext = null) { return Build (entry, false, cancellationToken, operationContext); }
public AsyncOperation<BuildResult> Rebuild (IBuildTarget entry, OperationContext operationContext = null) { if (currentBuildOperation != null && !currentBuildOperation.IsCompleted) return currentBuildOperation; var cs = new CancellationTokenSource (); ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetRebuildProgressMonitor ().WithCancellationSource (cs); var t = RebuildAsync (entry, monitor, operationContext); t = t.ContinueWith (ta => { currentBuildOperationOwner = null; return ta.Result; }); var op = new AsyncOperation<BuildResult> (t, cs); return currentBuildOperation = op; }
protected override async Task<BuildResult> OnBuild(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { var result = await base.OnBuild(monitor, configuration, operationContext); try { if (!result.Failed && IsSupportedProject) { // rename plugin output to .rhi or .ghp disableOutputNameChange = true; var file = Project.GetOutputFileName(configuration); disableOutputNameChange = false; var ext = PluginExtension; if (file.Extension != ext) { RenameOutputFile(file, file.ChangeExtension(ext)); RenameOutputFile(file.ChangeExtension(file.Extension + ".mdb"), file.ChangeExtension(ext + ".mdb")); } } } catch (Exception ex) { monitor.ReportError($"An error occurred renaming output files to .rhi/.ghp.\n{ex}", ex); } return result; }
protected override async Task<BuildResult> OnClean(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { try { if (IsSupportedProject) { // clean up the renamed output files disableOutputNameChange = true; var file = Project.GetOutputFileName(configuration); disableOutputNameChange = false; var ext = PluginExtension; if (file.Extension != ext) { var assemblyFile = file.ChangeExtension(ext); if (File.Exists(assemblyFile)) File.Delete(assemblyFile); var debugFile = file.ChangeExtension(ext + ".mdb"); if (File.Exists(debugFile)) File.Delete(debugFile); } } } catch (Exception ex) { monitor.ReportError($"An error occurred cleaning output files.\n{ex}", ex); } return await base.OnClean(monitor, configuration, operationContext); }
protected override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { var r = new BuildResult (); r.AddError (UnsupportedProjectMessage); return Task.FromResult (r); }
protected override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { return Task.FromResult (BuildResult.CreateSuccess ()); }
public AsyncOperation Clean (IBuildTarget entry, OperationContext operationContext = null) { if (currentBuildOperation != null && !currentBuildOperation.IsCompleted) return currentBuildOperation; ITimeTracker tt = Counters.BuildItemTimer.BeginTiming ("Cleaning " + entry.Name); try { var cs = new CancellationTokenSource (); ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetCleanProgressMonitor ().WithCancellationSource (cs); OnStartClean (monitor, tt); var t = CleanAsync (entry, monitor, tt, false, operationContext); t = t.ContinueWith (ta => { currentBuildOperationOwner = null; return ta.Result; }); var op = new AsyncOperation<BuildResult> (t, cs); currentBuildOperation = op; currentBuildOperationOwner = entry; } catch { tt.End (); throw; } return currentBuildOperation; }
async Task<BuildResult> CleanAsync (IBuildTarget entry, ProgressMonitor monitor, ITimeTracker tt, bool isRebuilding, OperationContext operationContext) { BuildResult res = null; try { tt.Trace ("Cleaning item"); res = await entry.Clean (monitor, IdeApp.Workspace.ActiveConfiguration, operationContext); } catch (Exception ex) { monitor.ReportError (GettextCatalog.GetString ("Clean failed."), ex); } finally { tt.Trace ("Done cleaning"); } if (isRebuilding) { if (EndClean != null) { OnEndClean (monitor, tt); } } else { CleanDone (monitor, entry, tt); } return res; }
public ProjectOperationContext (OperationContext other): this () { if (other != null) CopyFrom (other); }
async Task<BuildResult> RebuildAsync (IBuildTarget entry, ProgressMonitor monitor, OperationContext operationContext) { ITimeTracker tt = Counters.BuildItemTimer.BeginTiming ("Rebuilding " + entry.Name); try { OnStartClean (monitor, tt); var res = await CleanAsync (entry, monitor, tt, true, operationContext); if (res.HasErrors) { tt.End (); monitor.Dispose (); return res; } if (StartBuild != null) { BeginBuild (monitor, tt, true); } return await BuildSolutionItemAsync (entry, monitor, tt, operationContext:operationContext); } finally { tt.End (); } }
internal protected virtual Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { return next.OnBuild (monitor, configuration, operationContext); }
AsyncOperation<BuildResult> Build (IBuildTarget entry, bool skipPrebuildCheck, CancellationToken? cancellationToken = null, OperationContext operationContext = null) { if (currentBuildOperation != null && !currentBuildOperation.IsCompleted) return currentBuildOperation; ITimeTracker tt = Counters.BuildItemTimer.BeginTiming ("Building " + entry.Name); try { var cs = new CancellationTokenSource (); if (cancellationToken != null) cs = CancellationTokenSource.CreateLinkedTokenSource (cs.Token, cancellationToken.Value); ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor ().WithCancellationSource (cs); BeginBuild (monitor, tt, false); var t = BuildSolutionItemAsync (entry, monitor, tt, skipPrebuildCheck, operationContext); currentBuildOperation = new AsyncOperation<BuildResult> (t, cs); currentBuildOperationOwner = entry; t.ContinueWith ((ta) => currentBuildOperationOwner = null); } catch { tt.End (); throw; } return currentBuildOperation; }
//FIXME: Check whether autogen.sh is required or not protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.BuildTargetName)) return await base.OnBuild (monitor, configuration, operationContext); //FIXME: Gen autofoo ? autoreconf? string output = String.Empty; int exitCode = 0; monitor.BeginTask (GettextCatalog.GetString ("Building {0}", Project.Name), 1); try { string baseDir = Project.BaseDirectory; string args = string.Format ("-j {0} {1}", data.ParallelProcesses, data.BuildTargetName); using (var swOutput = new StringWriter ()) { using (var chainedOutput = new LogTextWriter ()) { chainedOutput.ChainWriter (monitor.Log); chainedOutput.ChainWriter (swOutput); using (ProcessWrapper process = Runtime.ProcessService.StartProcess ("make", args, baseDir, chainedOutput, chainedOutput, null)) { await process.Task; chainedOutput.UnchainWriter (monitor.Log); chainedOutput.UnchainWriter (swOutput); exitCode = process.ExitCode; output = swOutput.ToString (); monitor.Step ( 1 ); } } } } catch ( Exception e ) { monitor.ReportError ( GettextCatalog.GetString ("Project could not be built: "), e ); return null; } finally { monitor.EndTask (); } TempFileCollection tf = new TempFileCollection (); Regex regexError = data.GetErrorRegex (false); Regex regexWarning = data.GetWarningRegex (false); BuildResult cr = ParseOutput (tf, output, Project.BaseDirectory, regexError, regexWarning); if (exitCode != 0 && cr.FailedBuildCount == 0) cr.AddError (GettextCatalog.GetString ("Build failed. See Build Output panel.")); return cr; }
protected override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { foreach (Package p in packages) p.Clean (monitor); return Task.FromResult (BuildResult.CreateSuccess ()); }
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 (); }
protected override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { //if no files are set to compile, then some compilers will error out //though this is valid with ASP.NET apps, so we just avoid calling the compiler in this case bool needsCompile = false; foreach (ProjectFile pf in Project.Files) { if (pf.BuildAction == BuildAction.Compile) { needsCompile = true; break; } } if (needsCompile) return base.OnBuild (monitor, configuration, operationContext); return Task.FromResult (BuildResult.CreateSuccess ()); }
public Task <BuildResult> Build(ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null) { var slnConf = ParentSolution?.GetConfiguration(configuration); if (slnConf == null) { return(Task.FromResult(new BuildResult())); } //don't collect dependencies, BuildItems will do it var collected = new HashSet <SolutionItem> (); CollectBuildableEntries(collected, configuration, slnConf, false); return(ParentSolution.BuildItems( monitor, configuration, collected, operationContext, IsRoot ? GettextCatalog.GetString("Building solution {0} ({1})", Name, configuration.ToString()) : null )); }