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 RestoreTargetGraph(IEnumerable <ResolverConflict> conflicts,
                                   bool writeToLockFile,
                                   NuGetFramework framework,
                                   string runtimeIdentifier,
                                   RuntimeGraph runtimeGraph,
                                   IEnumerable <GraphNode <RemoteResolveResult> > graphs,
                                   ISet <RemoteMatch> install,
                                   ISet <GraphItem <RemoteResolveResult> > flattened,
                                   ISet <LibraryRange> unresolved,
                                   AnalyzeResult <RemoteResolveResult> analyzeResult)
        {
            Conflicts         = conflicts;
            WriteToLockFile   = writeToLockFile;
            RuntimeIdentifier = runtimeIdentifier;
            RuntimeGraph      = runtimeGraph;
            Framework         = framework;
            Graphs            = graphs;
            Name = FrameworkRuntimePair.GetName(Framework, RuntimeIdentifier);

            Conventions = new ManagedCodeConventions(runtimeGraph);

            Install       = install;
            Flattened     = flattened;
            AnalyzeResult = analyzeResult;
            Unresolved    = unresolved;
        }
Esempio n. 4
0
        private async Task <RestoreTargetGraph> WalkDependenciesAsync(LibraryRange projectRange,
                                                                      NuGetFramework framework,
                                                                      string runtimeIdentifier,
                                                                      RuntimeGraph runtimeGraph,
                                                                      RemoteDependencyWalker walker,
                                                                      RemoteWalkContext context,
                                                                      CancellationToken token)
        {
            var name   = FrameworkRuntimePair.GetName(framework, runtimeIdentifier);
            var graphs = new List <GraphNode <RemoteResolveResult> >();

            graphs.Add(await walker.WalkAsync(
                           projectRange,
                           framework,
                           runtimeIdentifier,
                           runtimeGraph,
                           recursive: true));

            // Resolve conflicts
            _logger.LogVerbose(string.Format(CultureInfo.CurrentCulture, Strings.Log_ResolvingConflicts, name));

            // Flatten and create the RestoreTargetGraph to hold the packages
            var result = RestoreTargetGraph.Create(runtimeGraph, graphs, context, _logger, framework, runtimeIdentifier);

            // Check if the dependencies got bumped up
            if (_request.ExistingLockFile == null)
            {
                // No lock file, so check dependencies
                CheckDependencies(result, _request.Project.Dependencies);

                var fxInfo = _request.Project.GetTargetFramework(framework);
                if (fxInfo != null)
                {
                    CheckDependencies(result, fxInfo.Dependencies);
                }
            }

            return(result);
        }
 public NugetRepositoryEntryBuilder WithTarget(FrameworkRuntimePair target)
 {
     _targets.Add(target);
     return(this);
 }
Esempio n. 6
0
        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.GetName(graph.Framework, runtimeName)));

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

            return(Task.WhenAll(resultGraphs));
        }
Esempio n. 7
0
        private async Task <RestoreTargetGraph> WalkDependenciesAsync(LibraryRange projectRange,
                                                                      NuGetFramework framework,
                                                                      string runtimeIdentifier,
                                                                      RuntimeGraph runtimeGraph,
                                                                      RemoteDependencyWalker walker,
                                                                      RemoteWalkContext context,
                                                                      bool writeToLockFile,
                                                                      CancellationToken token)
        {
            var name   = FrameworkRuntimePair.GetName(framework, runtimeIdentifier);
            var graphs = new List <GraphNode <RemoteResolveResult> >();

            if (_request.ExistingLockFile != null && _request.ExistingLockFile.IsLocked)
            {
                // Walk all the items in the lock file target and just synthesize the outer graph
                var target = _request.ExistingLockFile.GetTarget(framework, runtimeIdentifier);

                token.ThrowIfCancellationRequested();
                if (target != null)
                {
                    foreach (var targetLibrary in target.Libraries)
                    {
                        token.ThrowIfCancellationRequested();

                        var library = _request.ExistingLockFile.GetLibrary(targetLibrary.Name, targetLibrary.Version);
                        if (library == null)
                        {
                            _logger.LogWarning(string.Format(CultureInfo.CurrentCulture, Strings.Log_LockFileMissingLibraryForTargetLibrary,
                                                             targetLibrary.Name,
                                                             targetLibrary.Version,
                                                             target.Name));
                            continue; // This library is not in the main lockfile?
                        }

                        var range = new LibraryRange()
                        {
                            Name           = library.Name,
                            TypeConstraint = LibraryDependencyTargetUtils.Parse(library.Type),
                            VersionRange   = new VersionRange(
                                minVersion: library.Version,
                                includeMinVersion: true,
                                maxVersion: library.Version,
                                includeMaxVersion: true)
                        };
                        graphs.Add(await walker.WalkAsync(
                                       range,
                                       framework,
                                       runtimeIdentifier,
                                       runtimeGraph,
                                       recursive: false));
                    }
                }
            }
            else
            {
                graphs.Add(await walker.WalkAsync(
                               projectRange,
                               framework,
                               runtimeIdentifier,
                               runtimeGraph,
                               recursive: true));
            }

            // Resolve conflicts
            _logger.LogVerbose(string.Format(CultureInfo.CurrentCulture, Strings.Log_ResolvingConflicts, name));

            // Flatten and create the RestoreTargetGraph to hold the packages
            var result = RestoreTargetGraph.Create(writeToLockFile, runtimeGraph, graphs, context, _logger, framework, runtimeIdentifier);

            // Check if the dependencies got bumped up
            // ...but not if there is an existing locked lock file.
            if (_request.ExistingLockFile == null || !_request.ExistingLockFile.IsLocked)
            {
                // No lock file, OR the lock file is unlocked, so check dependencies
                CheckDependencies(result, _request.Project.Dependencies);

                var fxInfo = _request.Project.GetTargetFramework(framework);
                if (fxInfo != null)
                {
                    CheckDependencies(result, fxInfo.Dependencies);
                }
            }

            return(result);
        }