private static IBuildQueueJob CreateNewBuildJob( ComponentConfiguration componentConfiguration, CancellationTokenSource <CompileCancellationToken> cancellationTokenSource, ProgressToken progressToken, IJobCollection jobCollection) { IBuildableComponentSubtype buildableComponentSubtype = (IBuildableComponentSubtype)componentConfiguration.ComponentSubtype; string outputFilePath = buildableComponentSubtype.GetOutputTopLevelFilePath(componentConfiguration); if (jobCollection.JobInProgress(outputFilePath)) { throw new CommandLineOperationException($"Build at {outputFilePath} is already in progress."); } BuildId currentBuildId = buildableComponentSubtype.CreateBuildId(componentConfiguration); BuildQueueJobId buildQueueJobId = BuildQueueJobExtension.CreateBuildQueueJobId(currentBuildId); IBuildQueueJob job = jobCollection.CreateNewJob( buildQueueJobId, componentConfiguration.ComponentDefinition.ReferencingEnvoy, buildableComponentSubtype.XmlName, outputFilePath, cancellationTokenSource, progressToken); return(job); }
/// <summary> /// Constructs an instance of a <see cref="CommandLineBuildJobMonitor"/>. Creates a build job for a component build and /// begins monitoring the job collection for child jobs to be added. /// </summary> /// <param name="componentConfiguration">The <see cref="ComponentConfiguration"/> for the component build being monitored.</param> /// <param name="progressToken">Progress token to create the build job with.</param> /// <param name="cancellationTokenSource">Cancellation token source to create the build job with.</param> public CommandLineBuildJobMonitor( ComponentConfiguration componentConfiguration, ProgressToken progressToken, CancellationTokenSource <CompileCancellationToken> cancellationTokenSource) { _jobFinishedCompletionSource = new TaskCompletionSource <object>(); _jobCollection = componentConfiguration.Host.GetSharedExportedValue <IJobCollection>(); _jobCollection.CollectionChanged += JobCollectionOnCollectionChanged; _rootJob = CreateNewBuildJob(componentConfiguration, cancellationTokenSource, progressToken, _jobCollection); if (_rootJob == null) { throw new CommandLineOperationException(LocalizedStrings.BuildComponentTool_FailToStartBuildErrorMessage); } SubscribeToRootJobFinishedEvent(); }
private static void WriteErrorsFromJob(IBuildQueueJob job) { var componentEnvoy = job.AssociatedEnvoy; IEnumerable <MessageInfo> errors; if (ComponentExtensions.ComponentHasBuildOrCompileErrors(componentEnvoy, out errors)) { CommandLineInterfaceApplication.WriteError(CreateComponentBuildErrorMessage(componentEnvoy.Name.Last, errors.ToList())); } else { CommandLineInterfaceApplication.WriteError( string.Format( CultureInfo.CurrentCulture, LocalizedStrings.BuildComponentTool_BuildFailedWithoutErrorMessages, componentEnvoy.Name.Last)); } }