コード例 #1
0
		public virtual void CopyFrom (OperationContext other)
		{
			if (other.customData != null)
				customData = new Dictionary<object, object> (other.customData);
			else
				customData = null;
		}
コード例 #2
0
		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 ();
		}
コード例 #3
0
		public override void CopyFrom (OperationContext other)
		{
			base.CopyFrom (other);
			var o = other as ProjectOperationContext;
			if (o != null)
				GlobalProperties = new ProjectItemMetadata ((ProjectItemMetadata) o.GlobalProperties);
		}
コード例 #4
0
		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;
		}
コード例 #5
0
		public override void CopyFrom (OperationContext other)
		{
			base.CopyFrom (other);
			var o = other as ProjectOperationContext;
			if (o != null)
				GlobalProperties = new Dictionary<string,string> (o.GlobalProperties);
		}
コード例 #6
0
		/// <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);
			}
		}
コード例 #7
0
		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);
		}
コード例 #8
0
		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);
			}
		}
コード例 #9
0
		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;
		}
コード例 #10
0
		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);
		}
コード例 #11
0
		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);
		}
コード例 #12
0
		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;
		}
コード例 #13
0
		public TargetEvaluationContext (OperationContext other): this ()
		{
			if (other != null)
				CopyFrom (other);
		}
コード例 #14
0
 protected override Task <BuildResult> OnBuild(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
 {
     return(Task.FromResult(BuildResult.CreateSuccess()));
 }
コード例 #15
0
		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;
		}
コード例 #16
0
		public AsyncOperation<BuildResult> Build (IBuildTarget entry, CancellationToken? cancellationToken = null, OperationContext operationContext = null)
		{
			return Build (entry, false, cancellationToken, operationContext);
		}
コード例 #17
0
		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);
    }
コード例 #20
0
		protected override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
		{
			var r = new BuildResult ();
			r.AddError (UnsupportedProjectMessage);
			return Task.FromResult (r);
		}
コード例 #21
0
		protected override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
		{
			return Task.FromResult (BuildResult.CreateSuccess ());
		}
コード例 #22
0
		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;
		}
コード例 #23
0
		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;
		}
コード例 #24
0
		public ProjectOperationContext (OperationContext other): this ()
		{
			if (other != null)
				CopyFrom (other);
		}
コード例 #25
0
		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 ();
			}
		}
コード例 #26
0
		internal protected virtual Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
		{
			return next.OnBuild (monitor, configuration, operationContext);
		}
コード例 #27
0
		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;
		}
コード例 #28
0
		//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;
		}
コード例 #29
0
		protected override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
		{
			foreach (Package p in packages)
				p.Clean (monitor);
			return Task.FromResult (BuildResult.CreateSuccess ());
		}
コード例 #30
0
		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 ();
		}
コード例 #31
0
		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 ());
		}
コード例 #32
0
        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
                       ));
        }