Exemple #1
0
        static void Main()
        {
            DependencyResolver rsol = new DependencyResolver(new string[]{@"C:\Program Files\_INFRA\TFS\Retail\Main\"});
            rsol.BuildTree();

            rsol.WriteTree();
            PackageDto sr =new PackageDto();
            sr.Version = "1.0.1.0";
            sr.Id = "CHBITS.Tools.Common.Security";

            IEnumerable<PackageDto> test;
            int generation = 0;
            do
            {
                Console.WriteLine("Gen: " + generation);

                test = rsol.GetPackagesToRebuild(sr, generation++);

                foreach (PackageDto dto in test)
                {
                    Console.WriteLine(dto.Id);

                }
                Console.WriteLine();

            } while (test != null && test.Count() != 0);

            Console.ReadLine();
        }
        /// <summary>
        /// Generation 0 = only direct attacheds
        /// Generation 1 = the first circle after the direct attacheds etc, without the inner ones!
        /// </summary>
        /// <param name="generation"></param>
        /// <returns></returns>
        public IEnumerable<PackageDto> GetPackagesToRebuild(PackageDto mainPackage, int generation)
        {
            List<PackageDto> packages = new List<PackageDto>();
            List<PackageDto> tempPackages = new List<PackageDto>();

            packages.Add(mainPackage);
            for (int i = 0; i < generation+1; i++)
            {
                //move one generation further
                tempPackages.Clear();
                tempPackages.AddRange(packages);
                packages.Clear();

                foreach (PackageDto package in tempPackages)
                {
                    foreach (Edge<PackageDto> subpkg in graph.InEdges(package))
                    {
                        packages.Add(subpkg.Source);

                    }
                }

            }

            return packages;
        }
Exemple #3
0
        private void readDefinedPackages()
        {
            if (File.Exists(_nugetDefinitionPath))
            {
                var reader = new XmlTextReader(_nugetDefinitionPath);
                XmlDocument _configFile = new XmlDocument();
                _configFile.Load(reader);
                XmlNamespaceManager nm = new XmlNamespaceManager(_configFile.NameTable);
                nm.AddNamespace("nuspec", "http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd");

                var root = (XmlElement)_configFile.SelectSingleNode("/nuspec:package/nuspec:metadata", nm);
                if (root == null) return;

                var dto = new PackageDto();
                dto.Id = root.SelectSingleNode("nuspec:id", nm).InnerText;
                dto.Version = root.SelectSingleNode("nuspec:version", nm).InnerText;
                dto.Target = "N/A";
                dto.Path = this._nugetDefinitionPath;
                _definedPackage = dto;

            }
        }
Exemple #4
0
        private void readUsedPackages()
        {
            if(File.Exists(_nugetIncludePath))
            {

                var reader = new XmlTextReader(_nugetIncludePath);
                XmlDocument _configFile = new XmlDocument();
                _configFile.Load(reader);

                XmlNodeList items = _configFile.SelectNodes("//packages/package");
                foreach(XmlElement elem in items.OfType<XmlElement>())
                {
                    var dto = new PackageDto();
                    dto.Id = elem.GetAttribute("id");
                    dto.Version = elem.GetAttribute("version");
                    dto.Target = elem.GetAttribute("targetFramework");
                    dto.Path = this._nugetIncludePath;
                    _usedPackages.Add(dto);
                }

            }
        }