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));
        }
Example #2
0
        private async Task <RestoreTargetGraph> WalkDependencies(LibraryRange projectRange, NuGetFramework framework, string runtimeIdentifier, RuntimeGraph runtimeGraph, RemoteDependencyWalker walker, RemoteWalkContext context)
        {
            _log.LogInformation($"Restoring packages for {framework}");
            var graph = await walker.Walk(
                projectRange,
                framework,
                runtimeIdentifier,
                runtimeGraph);

            // Resolve conflicts
            _log.LogVerbose($"Resolving Conflicts for {framework}");
            bool inConflict = !graph.TryResolveConflicts();

            // Flatten and create the RestoreTargetGraph to hold the packages
            return(RestoreTargetGraph.Create(inConflict, framework, runtimeIdentifier, runtimeGraph, graph, context, _loggerFactory));
        }
Example #3
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);
        }
Example #4
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);
        }