private async Task <RestoreTargetGraph> WalkDependenciesAsync(LibraryRange projectRange,
                                                                      NuGetFramework framework,
                                                                      string runtimeIdentifier,
                                                                      RuntimeGraph runtimeGraph,
                                                                      RemoteDependencyWalker walker,
                                                                      RemoteWalkContext context,
                                                                      CancellationToken token)
        {
            var name   = FrameworkRuntimePair.GetTargetGraphName(framework, runtimeIdentifier);
            var graphs = new List <GraphNode <RemoteResolveResult> >
            {
                await walker.WalkAsync(
                    projectRange,
                    framework,
                    runtimeIdentifier,
                    runtimeGraph,
                    recursive : true)
            };

            // Resolve conflicts
            await _logger.LogAsync(LogLevel.Verbose, string.Format(CultureInfo.CurrentCulture, Strings.Log_ResolvingConflicts, name));

            // Flatten and create the RestoreTargetGraph to hold the packages
            return(RestoreTargetGraph.Create(runtimeGraph, graphs, context, _logger, framework, runtimeIdentifier));
        }
        private RestoreTargetGraph(IEnumerable <ResolverConflict> conflicts,
                                   NuGetFramework framework,
                                   string runtimeIdentifier,
                                   RuntimeGraph runtimeGraph,
                                   IEnumerable <GraphNode <RemoteResolveResult> > graphs,
                                   ISet <RemoteMatch> install,
                                   ISet <GraphItem <RemoteResolveResult> > flattened,
                                   ISet <LibraryRange> unresolved,
                                   AnalyzeResult <RemoteResolveResult> analyzeResult,
                                   ISet <ResolvedDependencyKey> resolvedDependencies)
        {
            Conflicts         = conflicts.ToArray();
            RuntimeIdentifier = runtimeIdentifier;
            RuntimeGraph      = runtimeGraph;
            Framework         = framework;
            Graphs            = graphs;
            Name            = FrameworkRuntimePair.GetName(Framework, RuntimeIdentifier);
            TargetGraphName = FrameworkRuntimePair.GetTargetGraphName(Framework, RuntimeIdentifier);


            Conventions = new ManagedCodeConventions(runtimeGraph);

            Install              = install;
            Flattened            = flattened;
            AnalyzeResult        = analyzeResult;
            Unresolved           = unresolved;
            ResolvedDependencies = resolvedDependencies;
        }
        private Task <RestoreTargetGraph[]> WalkRuntimeDependenciesAsync(LibraryRange projectRange,
                                                                         RestoreTargetGraph graph,
                                                                         IEnumerable <string> runtimeIds,
                                                                         RemoteDependencyWalker walker,
                                                                         RemoteWalkContext context,
                                                                         RuntimeGraph runtimes,
                                                                         CancellationToken token)
        {
            var resultGraphs = new List <Task <RestoreTargetGraph> >();

            foreach (var runtimeName in runtimeIds)
            {
                _logger.LogVerbose(string.Format(CultureInfo.CurrentCulture, Strings.Log_RestoringPackages, FrameworkRuntimePair.GetTargetGraphName(graph.Framework, runtimeName)));

                resultGraphs.Add(WalkDependenciesAsync(projectRange,
                                                       graph.Framework,
                                                       runtimeName,
                                                       runtimes,
                                                       walker,
                                                       context,
                                                       token));
            }

            return(Task.WhenAll(resultGraphs));
        }