private static async Task<IList<CompatibilityCheckResult>> VerifyCompatibilityAsync( PackageSpec project, Dictionary<RestoreTargetGraph, Dictionary<string, LibraryIncludeFlags>> includeFlagGraphs, IReadOnlyList<NuGetv3LocalRepository> localRepositories, LockFile lockFile, IEnumerable<RestoreTargetGraph> graphs, bool validateRuntimeAssets, ILogger logger) { // Scan every graph for compatibility, as long as there were no unresolved packages var checkResults = new List<CompatibilityCheckResult>(); if (graphs.All(g => !g.Unresolved.Any())) { var checker = new CompatibilityChecker(localRepositories, lockFile, validateRuntimeAssets, logger); foreach (var graph in graphs) { await logger.LogAsync(LogLevel.Verbose, string.Format(CultureInfo.CurrentCulture, Strings.Log_CheckingCompatibility, graph.Name)); var includeFlags = IncludeFlagUtils.FlattenDependencyTypes(includeFlagGraphs, project, graph); var res = await checker.CheckAsync(graph, includeFlags); checkResults.Add(res); if (res.Success) { await logger.LogAsync(LogLevel.Verbose, string.Format(CultureInfo.CurrentCulture, Strings.Log_PackagesAndProjectsAreCompatible, graph.Name)); } else { // Get error counts on a project vs package basis var projectCount = res.Issues.Count(issue => issue.Type == CompatibilityIssueType.ProjectIncompatible); var packageCount = res.Issues.Count(issue => issue.Type != CompatibilityIssueType.ProjectIncompatible); // Log a summary with compatibility error counts if (projectCount > 0) { await logger.LogAsync(LogLevel.Debug, $"Incompatible projects: {projectCount}"); } if (packageCount > 0) { await logger.LogAsync(LogLevel.Debug, $"Incompatible packages: {packageCount}"); } } } } return checkResults; }
public static LockFileTargetLibrary CreateLockFileTargetLibrary( LockFileLibrary library, LocalPackageInfo package, RestoreTargetGraph targetGraph, LibraryIncludeFlags dependencyType, NuGetFramework targetFrameworkOverride, IEnumerable <LibraryDependency> dependencies, LockFileBuilderCache cache) { LockFileTargetLibrary lockFileLib = null; var runtimeIdentifier = targetGraph.RuntimeIdentifier; var framework = targetFrameworkOverride ?? targetGraph.Framework; // This will throw an appropriate error if the nuspec is missing var nuspec = package.Nuspec; var orderedCriteriaSets = cache.GetSelectionCriteria(targetGraph, framework); var contentItems = cache.GetContentItems(library, package); var packageTypes = nuspec.GetPackageTypes().AsList(); for (var i = 0; i < orderedCriteriaSets.Count; i++) { // Create a new library each time to avoid // assets being added from other criteria. lockFileLib = new LockFileTargetLibrary() { Name = package.Id, Version = package.Version, Type = LibraryType.Package, PackageType = packageTypes }; // Populate assets if (lockFileLib.PackageType.Contains(PackageType.DotnetTool)) { AddToolsAssets(library, package, targetGraph, dependencyType, lockFileLib, framework, runtimeIdentifier, contentItems, nuspec, orderedCriteriaSets[i]); if (CompatibilityChecker.HasCompatibleToolsAssets(lockFileLib)) { break; } } else { AddAssets(library, package, targetGraph, dependencyType, lockFileLib, framework, runtimeIdentifier, contentItems, nuspec, orderedCriteriaSets[i]); // Check if compatile assets were found. // If no compatible assets were found and this is the last check // continue on with what was given, this will fail in the normal // compat verification. if (CompatibilityChecker.HasCompatibleAssets(lockFileLib)) { // Stop when compatible assets are found. break; } } } // Add dependencies AddDependencies(dependencies, lockFileLib, framework, nuspec); // Exclude items ExcludeItems(lockFileLib, dependencyType); return(lockFileLib); }