public static IEnumerable <ExternalProjectReference> GetExternalClosure(DependencyGraphSpec dgFile, string projectNameToRestore) { var closure = dgFile.GetClosure(projectNameToRestore); var externalClosure = closure.Select(GetExternalProject); return(externalClosure); }
private IReadOnlyList <RestoreSummaryRequest> GetRequestsFromItems(RestoreArgs restoreContext, DependencyGraphSpec dgFile) { if (restoreContext == null) { throw new ArgumentNullException(nameof(restoreContext)); } if (dgFile == null) { throw new ArgumentNullException(nameof(dgFile)); } // Write the dg file to disk of the NUGET_PERSIST_DG is set. MSBuildRestoreUtility.PersistDGFileIfDebugging(dgFile, restoreContext.Log); // Validate the dg file input, this throws if errors are found. SpecValidationUtility.ValidateDependencySpec(dgFile); // Create requests var requests = new List <RestoreSummaryRequest>(); var toolRequests = new List <RestoreSummaryRequest>(); foreach (var projectNameToRestore in dgFile.Restore) { var closure = dgFile.GetClosure(projectNameToRestore); var projectDependencyGraphSpec = dgFile.WithProjectClosure(projectNameToRestore); var externalClosure = new HashSet <ExternalProjectReference>(closure.Select(GetExternalProject)); var rootProject = externalClosure.Single(p => StringComparer.Ordinal.Equals(projectNameToRestore, p.UniqueName)); var request = Create(projectNameToRestore, rootProject, externalClosure, restoreContext, projectDgSpec: projectDependencyGraphSpec); if (request.Request.ProjectStyle == ProjectStyle.DotnetCliTool) { // Store tool requests to be filtered later toolRequests.Add(request); } else { requests.Add(request); } } // Filter out duplicate tool restore requests requests.AddRange(ToolRestoreUtility.GetSubSetRequests(toolRequests)); return(requests); }
private IReadOnlyList <RestoreSummaryRequest> GetRequestsFromItems(RestoreArgs restoreContext, DependencyGraphSpec dgFile) { if (restoreContext == null) { throw new ArgumentNullException(nameof(restoreContext)); } if (dgFile == null) { throw new ArgumentNullException(nameof(dgFile)); } // Validate the dg file input, this throws if errors are found. SpecValidationUtility.ValidateDependencySpec(dgFile); // Create requests var requests = new ConcurrentBag <RestoreSummaryRequest>(); var toolRequests = new ConcurrentBag <RestoreSummaryRequest>(); var parallelOptions = new ParallelOptions { // By default, max degree of parallelism is -1 which means no upper bound. // Limiting to processor count reduces task context switching which is better MaxDegreeOfParallelism = Environment.ProcessorCount }; using (var settingsLoadingContext = new SettingsLoadingContext()) { // Parallel.Foreach has an optimization for Arrays, so calling .ToArray() is better and adds almost no overhead Parallel.ForEach(dgFile.Restore.ToArray(), parallelOptions, projectNameToRestore => { IReadOnlyList <PackageSpec> closure = dgFile.GetClosure(projectNameToRestore); DependencyGraphSpec projectDependencyGraphSpec = dgFile.CreateFromClosure(projectNameToRestore, closure); var externalClosure = new HashSet <ExternalProjectReference>(closure.Select(GetExternalProject)); ExternalProjectReference rootProject = externalClosure.Single(p => StringComparer.Ordinal.Equals(projectNameToRestore, p.UniqueName)); RestoreSummaryRequest request = Create( projectNameToRestore, rootProject, externalClosure, restoreContext, projectDependencyGraphSpec, settingsLoadingContext); if (request.Request.ProjectStyle == ProjectStyle.DotnetCliTool) { // Store tool requests to be filtered later toolRequests.Add(request); } else { requests.Add(request); } }); } // Filter out duplicate tool restore requests foreach (RestoreSummaryRequest subSetRequest in ToolRestoreUtility.GetSubSetRequests(toolRequests)) { requests.Add(subSetRequest); } return(requests.ToArray()); }
public static IEnumerable <ExternalProjectReference> GetExternalClosure(DependencyGraphSpec dgFile, string projectNameToRestore) { IReadOnlyList <PackageSpec> closure = dgFile.GetClosure(projectNameToRestore); return(closure.Select(GetExternalProject)); }