public void CanCleanPackageFolders(string repositoryConfig)
        {
            var repositoryGroupManager = new RepositoryGroupManager(repositoryConfig, _mfs);

            foreach (var repositoryManager in repositoryGroupManager.RepositoryManagers)
            {
                if (repositoryManager.RepositoryConfig.Directory != null)
                {
                    _mfs.CreateDirectory(Path.Combine(repositoryManager.RepositoryConfig.Directory.Name, "Test"));
                }
            }

            //repositoryGroupManager.CleanPackageFolders();

            foreach (var repositoryManager in repositoryGroupManager.RepositoryManagers)
            {
                if (repositoryManager.RepositoryConfig.Directory != null)
                    Assert.AreEqual(0, _mfs.GetDirectories(repositoryManager.RepositoryConfig.Directory.Name).Count());
            }
        }
Beispiel #2
0
 /// <summary>
 /// Logs all package constraint satisfaction errors.
 /// </summary>
 /// <param name="repositoryGroupManager">The repository group manager.</param>
 /// <param name="packageAggregator">The package aggregator.</param>
 private void LogAllPackageConstraintSatisfactionErrors(RepositoryGroupManager repositoryGroupManager, PackageAggregator packageAggregator)
 {
     //HACK #UGLY #WTF There must be a better way....
     foreach (var p in packageAggregator.PackageResolveFailures)
     {
         foreach (var rp in repositoryGroupManager.RepositoryManagers)
         {
             foreach (var prf in rp.PackageReferenceFiles)
             {
                 if (prf.GetPackageReferences().Contains(p))
                 {
                     LogSatisfactionFailure(p, prf);
                 }
             }
         }
     }
 }
 public void ConstructParser(string repositoryConfigPath,int repositoryCount)
 {
     var repositoryManager = new RepositoryGroupManager(repositoryConfigPath, _mfs);
     Assert.IsNotNull(repositoryManager);
     Assert.AreEqual(repositoryCount, repositoryManager.RepositoryManagers.Count());
 }
Beispiel #4
0
        private void GetByDirectoryPath(IFileSystem baseFileSystem, string target)
        {
            if (baseFileSystem.DirectoryExists(target))
            {
                var repositoryGroupManager = new RepositoryGroupManager(target, baseFileSystem);
                var repositoryManagers = new ConcurrentBag<RepositoryManager>(repositoryGroupManager.RepositoryManagers);

                var totalTime = new Stopwatch();
                totalTime.Start();

                int totalPackageUpdates = 0;

                bool exitWithFailure = false;
                Array.ForEach(repositoryManagers.ToArray(), (repositoryManager) =>
                    {
                        string packagesConfigDiretory = null;

                        if (repositoryManager.RepositoryConfig.Directory != null)
                            packagesConfigDiretory = repositoryManager.RepositoryConfig.Directory.FullName;
                        
                        using (var packageAggregator = new PackageAggregator(baseFileSystem, repositoryManager, new PackageEnumerator()))
                        {
                            packageAggregator.Compute((min, max) =>
                                {
                                    totalPackageUpdates += Convert.ToInt16(min);
                                    Console.WriteLine("Getting {0} distinct packages from a total of {1} from {2}",min, max,repositoryManager.RepositoryConfig.FullName);
                                },
                                Latest ? PackageReferenceEqualityComparer.IdAndAllowedVersions : PackageReferenceEqualityComparer.IdVersionAndAllowedVersions , new PackageReferenceSetResolver());

                            if (packageAggregator.PackageResolveFailures.Any())
                            {
                                LogAllPackageConstraintSatisfactionErrors(repositoryGroupManager, packageAggregator);
                                exitWithFailure = true;
                            }
                            else
                            {
                                var tempPackageConfig = packageAggregator.Save(packagesConfigDiretory);
                                var installedPackagesList = InstallPackagesFromConfigFile(packagesConfigDiretory, GetPackageReferenceFile(baseFileSystem, tempPackageConfig.FullName), target);
                                if (TeamCityNugetXml)
                                    SaveNuGetXml(CreatePackagesConfigXml(installedPackagesList), TeamCityNuGetXmlOutputDirectory);
                            }
                        }
                    });

                totalTime.Stop();

                if (exitWithFailure)
                {
                    var errorMessage = string.Format("Failed : {0} package directories, {1} packages in {2} seconds",
                                                     repositoryManagers.Count, totalPackageUpdates,
                                                     totalTime.Elapsed.TotalSeconds);
                    throw new CommandLineException(errorMessage);
                }

                Console.WriteLine(string.Format("Updated : {0} package directories, {1} packages in {2} seconds",
                                                    repositoryManagers.Count, totalPackageUpdates,
                                                    totalTime.Elapsed.TotalSeconds));
            }
        }