Exemplo n.º 1
0
        public LibraryDescription GetDescription(ProjectLibraryDependency libraryDependency, NuGetFramework targetFramework)
        {
            if (!libraryDependency.LibraryRange.TypeConstraintAllows(LibraryDependencyTarget.Reference))
            {
                return(null);
            }

            var name    = libraryDependency.Name;
            var version = libraryDependency.LibraryRange.VersionRange?.MinVersion;

            string  path;
            Version assemblyVersion;

            if (!FrameworkResolver.TryGetAssembly(name, targetFramework, out path, out assemblyVersion))
            {
                return(null);
            }

            return(new LibraryDescription(
                       new LibraryIdentity(libraryDependency.Name, new NuGetVersion(assemblyVersion), LibraryType.Reference),
                       string.Empty, // Framework assemblies don't have hashes
                       path,
                       Enumerable.Empty <ProjectLibraryDependency>(),
                       targetFramework,
                       resolved: true,
                       compatible: true));
        }
        private PackageDependencyInfo ToPackageDependencyInfo(
            ProjectLibraryDependency dependency,
            IDictionary <string, PackageDependencyInfo> dependencyToVersionMap)
        {
            var name    = dependency.Name;
            var version = dependency.LibraryRange?.VersionRange?.OriginalString;

            if (dependencyToVersionMap.ContainsKey(name))
            {
                var dependencyInfo = dependencyToVersionMap[name];
                if (dependencyInfo == null)
                {
                    return(null);
                }

                name    = dependencyInfo.Name;
                version = dependencyInfo.Version;
            }

            return(new PackageDependencyInfo
            {
                Name = name,
                Version = version
            });
        }
Exemplo n.º 3
0
        private static string FormatLibraryRange(ProjectLibraryDependency range)
        {
            if (range.LibraryRange.VersionRange == null)
            {
                return(range.Name);
            }

            return(range.Name + " " + VersionUtility.RenderVersion(range.LibraryRange.VersionRange));
        }
Exemplo n.º 4
0
 public static LibraryDescription GetDescription(ProjectLibraryDependency libraryDependency, NuGetFramework targetFramework)
 {
     return(new LibraryDescription(
                new LibraryIdentity(
                    libraryDependency.Name,
                    libraryDependency.LibraryRange.VersionRange?.MinVersion,
                    GetLibraryTypeFromLibraryDependencyTarget(libraryDependency.LibraryRange.TypeConstraint)),
                hash: null,
                path: null,
                dependencies: Enumerable.Empty <ProjectLibraryDependency>(),
                framework: targetFramework,
                resolved: false,
                compatible: true));
 }
        private PackageDependencyInfo ToPackageDependencyInfo(
            ProjectLibraryDependency dependency,
            IDictionary <PackageDependencyInfo, PackageDependencyInfo> dependencyToVersionMap)
        {
            var name     = dependency.Name;
            var version  = dependency.LibraryRange?.VersionRange?.OriginalString;
            var minRange = dependency.LibraryRange?.VersionRange?.ToNonSnapshotRange().MinVersion;

            var possibleMappings =
                dependencyToVersionMap.Where(c => c.Key.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (possibleMappings.Any() && !string.IsNullOrEmpty(version))
            {
                var possibleVersions = possibleMappings.Select(p => VersionRange.Parse(p.Key.Version));
                var matchVersion     = possibleVersions.FirstOrDefault(p => p.Satisfies(minRange));
                if (matchVersion != null)
                {
                    var dependencyInfo = possibleMappings.First(c =>
                                                                c.Key.Version.Equals(matchVersion.OriginalString, StringComparison.OrdinalIgnoreCase)).Value;

                    if (dependencyInfo == null)
                    {
                        return(null);
                    }

                    name    = dependencyInfo.Name;
                    version = dependencyInfo.Version;
                }
            }

            return(new PackageDependencyInfo
            {
                Name = name,
                Version = version
            });
        }
        private PackageDependencyInfo ToPackageDependencyInfo(
            ProjectLibraryDependency dependency,
            IDictionary <string, string> toolsDictionary)
        {
            var name    = dependency.Name;
            var version = dependency.LibraryRange?.VersionRange?.OriginalString;

            if (toolsDictionary.ContainsKey(name))
            {
                name    = toolsDictionary[name];
                version = ConstantPackageVersions.AspNetToolsVersion;

                if (string.IsNullOrEmpty(name))
                {
                    return(null);
                }
            }

            return(new PackageDependencyInfo
            {
                Name = name,
                Version = version
            });
        }
Exemplo n.º 7
0
 public LibraryItem(ProjectLibraryDependency requestedRange, LibraryDescription library)
 {
     RequestedRange = requestedRange;
     Library        = library;
 }
Exemplo n.º 8
0
 public DependencyItem(ProjectLibraryDependency dependency, LibraryDescription library)
 {
     Dependency = dependency;
     Library    = library;
 }
Exemplo n.º 9
0
 private static string FormatLibraryRange(ProjectLibraryDependency range)
 {
     return(range.LibraryRange.ToLockFileDependencyGroupString());
 }