Esempio n. 1
0
        private static JProperty WriteFrameworkGroup(LockFileFrameworkGroup group)
        {
            var json = new JObject();

            json["dependencies"]        = WriteObject(group.Dependencies, WritePackageDependency);
            json["frameworkAssemblies"] = WriteArray(group.FrameworkAssemblies, WriteString);
            json["runtimeAssemblies"]   = WriteArray(group.RuntimeAssemblies, WriteString);
            json["compileAssemblies"]   = WriteArray(group.CompileTimeAssemblies, WriteString);

            return(new JProperty(group.TargetFramework.DotNetFrameworkName, json));
        }
Esempio n. 2
0
        private static LockFileFrameworkGroup ReadFrameworkGroup(string property, JToken json)
        {
            var group = new LockFileFrameworkGroup();

            group.TargetFramework       = NuGetFramework.Parse(property);
            group.Dependencies          = ReadObject(json["dependencies"] as JObject, ReadPackageDependency);
            group.FrameworkAssemblies   = ReadArray(json["frameworkAssemblies"] as JArray, ReadString);
            group.RuntimeAssemblies     = ReadArray(json["runtimeAssemblies"] as JArray, ReadString);
            group.CompileTimeAssemblies = ReadArray(json["compileAssemblies"] as JArray, ReadString);

            return(group);
        }
        private IList <LibraryDependency> GetDependencies(LockFileFrameworkGroup frameworkGroup)
        {
            var libraryDependencies = new List <LibraryDependency>();

            if (frameworkGroup.Dependencies != null)
            {
                foreach (var d in frameworkGroup.Dependencies)
                {
                    libraryDependencies.Add(new LibraryDependency
                    {
                        LibraryRange = new LibraryRange
                        {
                            Name         = d.Id,
                            VersionRange = d.VersionRange
                        }
                    });
                }
            }

            if (!frameworkGroup.TargetFramework.IsDesktop())
            {
                // REVIEW: This isn't 100% correct since none *can* mean
                // any in theory, but in practice it means .NET full reference assembly
                // If there's no supported target frameworks and we're not targeting
                // the desktop framework then skip it.

                // To do this properly we'll need all reference assemblies supported
                // by each supported target framework which isn't always available.
                return(libraryDependencies);
            }

            foreach (var name in frameworkGroup.FrameworkAssemblies)
            {
                libraryDependencies.Add(new LibraryDependency
                {
                    LibraryRange = new LibraryRange
                    {
                        Name           = name,
                        TypeConstraint = LibraryTypes.Reference
                    }
                });
            }

            return(libraryDependencies);
        }