/// <summary> /// Uses <see cref="MsBuildPipConstructor"/> to schedule the specified projects and retrieves the result internal MsBuildSchedulingResult ScheduleAll(MsBuildResolverSettings resolverSettings, IEnumerable <ProjectWithPredictions> projectsWithPredictions, QualifierId currentQualifier, QualifierId[] requestedQualifiers) { var moduleRegistry = new ModuleRegistry(FrontEndContext.SymbolTable); var frontEndFactory = CreateFrontEndFactoryForEvaluation(ParseAndEvaluateLogger); using (var controller = CreateFrontEndHost(GetDefaultCommandLine(), frontEndFactory, moduleRegistry, AbsolutePath.Invalid, out _, out _, requestedQualifiers)) { resolverSettings.ComputeEnvironment(out var trackedEnv, out var passthroughVars, out _); var pipConstructor = new PipConstructor( FrontEndContext, controller, m_testModule, resolverSettings, resolverSettings.ShouldRunDotNetCoreMSBuild()? DotnetCoreMSBuild : FullframeworkMSBuild, resolverSettings.ShouldRunDotNetCoreMSBuild()? DotnetExe : AbsolutePath.Invalid, nameof(MsBuildFrontEnd), trackedEnv, passthroughVars); var schedulingResults = new Dictionary <ProjectWithPredictions, (bool, string, Process)>(); foreach (var projectWithPredictions in projectsWithPredictions) { var result = pipConstructor.TrySchedulePipForFile(projectWithPredictions, currentQualifier, out string failureDetail, out Process process); schedulingResults[projectWithPredictions] = (result, failureDetail, process); } return(new MsBuildSchedulingResult(PathTable, controller.PipGraph, schedulingResults)); } }
/// <summary> /// Uses <see cref="MsBuildPipConstructor"/> to schedule the specified projects and retrieves the result internal MsBuildSchedulingResult ScheduleAll(MsBuildResolverSettings resolverSettings, IEnumerable <ProjectWithPredictions> projectsWithPredictions, QualifierId currentQualifier, QualifierId[] requestedQualifiers) { var moduleRegistry = new ModuleRegistry(FrontEndContext.SymbolTable); var workspaceFactory = CreateWorkspaceFactoryForTesting(FrontEndContext, ParseAndEvaluateLogger); var frontEndFactory = CreateFrontEndFactoryForEvaluation(workspaceFactory, ParseAndEvaluateLogger); using (var controller = CreateFrontEndHost(GetDefaultCommandLine(), frontEndFactory, workspaceFactory, moduleRegistry, AbsolutePath.Invalid, out _, out _, requestedQualifiers)) { var pipConstructor = new PipConstructor( FrontEndContext, controller, m_testModule, resolverSettings, AbsolutePath.Create(PathTable, TestDeploymentDir).Combine(PathTable, "MSBuild.exe"), nameof(MsBuildFrontEnd)); var schedulingResults = new Dictionary <ProjectWithPredictions, (bool, string, Process)>(); foreach (var projectWithPredictions in projectsWithPredictions) { var result = pipConstructor.TrySchedulePipForFile(projectWithPredictions, currentQualifier, out string failureDetail, out Process process); schedulingResults[projectWithPredictions] = (result, failureDetail, process); } return(new MsBuildSchedulingResult(PathTable, controller.PipGraph, schedulingResults)); } }
/// <nodoc/> public MsBuildProjectBuilder(MsBuildPipSchedulingTestBase testBase, MsBuildResolverSettings resolverSettings, QualifierId qualifierId) { Contract.Requires(testBase != null); Contract.Requires(resolverSettings != null); Contract.Requires(qualifierId != QualifierId.Invalid); m_projects = new HashSet <ProjectWithPredictions>(); m_testBase = testBase; m_resolverSettings = resolverSettings; m_qualifierId = qualifierId; }
/// <nodoc/> public MsBuildProjectBuilder(MsBuildPipSchedulingTestBase testBase, MsBuildResolverSettings resolverSettings, QualifierId currentQualifier, QualifierId[] requestedQualifiers) { Contract.Requires(testBase != null); Contract.Requires(resolverSettings != null); Contract.Requires(currentQualifier != QualifierId.Invalid); Contract.Requires(requestedQualifiers?.Length > 0); m_projects = new HashSet <ProjectWithPredictions>(); m_testBase = testBase; m_resolverSettings = resolverSettings; m_qualifierId = currentQualifier; m_requestedQualifiers = requestedQualifiers; }
/// <summary> /// Starts the addition of projects /// </summary> /// <returns></returns> public MsBuildProjectBuilder Start(MsBuildResolverSettings resolverSettings = null, QualifierId qualifierId = default) { var settings = resolverSettings ?? new MsBuildResolverSettings(); // Make sure the Root is set if (settings.Root == AbsolutePath.Invalid) { settings.Root = AbsolutePath.Create(PathTable, TestRoot); } if (qualifierId == default) { qualifierId = FrontEndContext.QualifierTable.CreateQualifier(CollectionUtilities.EmptyDictionary <string, string>()); } return(new MsBuildProjectBuilder(this, settings, qualifierId)); }
/// <summary> /// Starts the addition of projects /// </summary> /// <returns></returns> public MsBuildProjectBuilder Start(MsBuildResolverSettings resolverSettings = null, QualifierId currentQualifier = default, QualifierId[] requestedQualifiers = default) { var settings = resolverSettings ?? new MsBuildResolverSettings(); // Make sure the Root is set if (settings.Root == AbsolutePath.Invalid) { settings.Root = AbsolutePath.Create(PathTable, TestRoot); } if (currentQualifier == default) { currentQualifier = FrontEndContext.QualifierTable.EmptyQualifierId; } if (requestedQualifiers == default) { requestedQualifiers = new QualifierId[] { FrontEndContext.QualifierTable.EmptyQualifierId }; } return(new MsBuildProjectBuilder(this, settings, currentQualifier, requestedQualifiers)); }
/// <summary> /// Uses <see cref="MsBuildPipConstructor"/> to schedule the specified projects and retrieves the result internal MsBuildSchedulingResult ScheduleAll(MsBuildResolverSettings resolverSettings, IEnumerable <ProjectWithPredictions> projectsWithPredictions, QualifierId currentQualifier, QualifierId[] requestedQualifiers) { var moduleRegistry = new ModuleRegistry(FrontEndContext.SymbolTable); var frontEndFactory = CreateFrontEndFactoryForEvaluation(ParseAndEvaluateLogger); using (var controller = CreateFrontEndHost(GetDefaultCommandLine(), frontEndFactory, moduleRegistry, AbsolutePath.Invalid, out _, out _, requestedQualifiers)) { resolverSettings.ComputeEnvironment(out var trackedEnv, out var passthroughVars, out _); var pipConstructor = new PipConstructor( FrontEndContext, controller, m_testModule, resolverSettings, resolverSettings.ShouldRunDotNetCoreMSBuild()? DotnetCoreMSBuild : FullframeworkMSBuild, resolverSettings.ShouldRunDotNetCoreMSBuild()? DotnetExe : AbsolutePath.Invalid, nameof(MsBuildFrontEnd), trackedEnv, passthroughVars); var schedulingResults = new Dictionary <ProjectWithPredictions, (bool, string, Process)>(); foreach (var projectWithPredictions in projectsWithPredictions) { // Is some tests projects are not finalized. Let's do it here. if (!projectWithPredictions.IsDependenciesSet) { projectWithPredictions.SetDependencies(CollectionUtilities.EmptyArray <ProjectWithPredictions>()); } var result = pipConstructor.TrySchedulePipForProject(projectWithPredictions, currentQualifier); schedulingResults[projectWithPredictions] = (result.Succeeded, result.Succeeded? null : result.Failure.Describe(), result.Succeeded? result.Result : null); } return(new MsBuildSchedulingResult(PathTable, controller.PipGraph, schedulingResults)); } }