Пример #1
0
        static void AddPackageReferences(PackageSpec packageSpec, IDotNetProject project)
        {
            foreach (var packageReference in project.GetPackageReferences())
            {
                var dependency = new LibraryDependency();

                dependency.LibraryRange = new LibraryRange(
                    name: packageReference.Include,
                    versionRange: GetVersionRange(packageReference),
                    typeConstraint: LibraryDependencyTarget.Package);

                ApplyIncludeFlags(dependency, packageReference);

                var frameworks = GetProjectFrameworks(project);

                if (frameworks.Count == 0)
                {
                    AddDependencyIfNotExist(packageSpec, dependency);
                }
                else
                {
                    foreach (var framework in frameworks)
                    {
                        AddDependencyIfNotExist(packageSpec, framework, dependency);
                    }
                }
            }
        }