/// <summary>
        /// Gets recursively every indirect dependencies related to a direct dependency.
        /// </summary>
        /// <param name="children">Child dependencies of a direct dependency.</param>
        /// <param name="dependencies">JToken object that represents every dependencies in assets file.</param>
        /// <returns></returns>
        private static List <NuGetPackage> GetIndirectDependencies(List <string> children, JToken dependencies)
        {
            List <NuGetPackage> deps = new List <NuGetPackage>();

            foreach (string child in children)
            {
                NuGetPackage package = new NuGetPackage
                {
                    Id       = child.Split(":")[0],
                    Version  = child.Split(":")[1],
                    Direct   = false,
                    Children = GetChildren(dependencies[child.Replace(":", "/")])
                };
                if (IsValidVersion(package))
                {
                    deps.Add(package);
                    deps.AddRange(GetIndirectDependencies(package.Children, dependencies));
                }
            }
            return(deps);
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            NuGetPackage package = (NuGetPackage)obj;

            return(package.Id == Id && package.Version == Version);
        }
 private static bool IsValidVersion(NuGetPackage package)
 {
     return(package.Version.StartsWith("$(") || Version.TryParse(package.Version, out Version v));
 }