Пример #1
0
 public RepushPackageCommand(
     IPackageCache packageCache,
     IPackageUrlParser packageUrlParser)
 {
     _packageCache = packageCache;
     _packageUrlParser = packageUrlParser;
 }
Пример #2
0
 public Get(IPackageRepositoryFactory packageRepositoryFactory, IPackageSourceProvider sourceProvider, IPackageRepository cacheRepository, IFileSystem fileSystem, IPackageCache packageCache)
     : this(packageRepositoryFactory, sourceProvider)
 {
     _cacheRepository = cacheRepository;
     OutputFileSystem = fileSystem;
     _packageCache    = packageCache;
 }
Пример #3
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        public override void ExecuteCommand()
        {
            //Probably need some better return code logic here...
            if (Arguments[0] == null)
            {
                return;
            }
            try
            {
                if (Source.Count == 1 && !NoFeedSpecificCache && !NoCache)
                {
                    _cacheManager = new NuGetCacheManager(Console);
                    _cacheManager.SetFeedSpecificCacheDirectory(_sources[0]);
                }

                if (!NoCache)
                {
                    if (_cacheRepository == null)
                    {
                        _cacheRepository = MachineCache.Default;
                    }
                }

                //TODO This needs injecting....
                if (_packageCache == null)
                {
                    _packageCache = new MemoryBasedPackageCache(Console);
                }

                _repository = GetRepository();
                _packageResolutionManager = new PackageResolutionManager(Console, Latest, _packageCache);

                //HACK need to inject somehow...
                _packageResolutionManager = _packageResolutionManager ?? new PackageResolutionManager(Console, Latest, new MemoryBasedPackageCache(Console));

                //Working on a package.config
                if (string.IsNullOrEmpty(_baseDirectory))
                {
                    _baseDirectory = Environment.CurrentDirectory;
                }

                var target = Arguments[0] == Path.GetFullPath(Arguments[0]) ? Arguments[0] : Path.GetFullPath(Path.Combine(_baseDirectory, Arguments[0]));
                if (Path.GetFileName(target).Equals(Constants.PackageReferenceFile, StringComparison.OrdinalIgnoreCase))
                {
                    OutputFileSystem = CreateFileSystem(Path.GetPathRoot(target));
                    GetByPackagesConfig(OutputFileSystem, target);
                }
                else
                {
                    OutputFileSystem = CreateFileSystem(Directory.GetParent(target).FullName);
                    GetByDirectoryPath(OutputFileSystem, target);
                }
            }
            catch (Exception e)
            {
                //HACK big catch here, but if anything goes wrong we want to log it and ensure a non-zero exit code...
                throw new CommandLineException(String.Format("GET Failed: {0}", e.Message), e);
            }
        }
Пример #4
0
 public PackageManager(
     IPackageCache packageCache,
     IPackageLookup packageLookup,
     IPackageLocator packageLocator)
 {
     this.m_PackageCache   = packageCache;
     _packageLookup        = packageLookup;
     this.m_PackageLocator = packageLocator;
 }
 public NuGetPackageExtractor(System.IO.Abstractions.IFileSystem fs, ILog log, IPackageCache packageCache,
                              TextWriter output, IInstanceConfiguration instanceConfiguration, IApplicationMap applicationMap)
 {
     _fs                    = fs;
     _log                   = log;
     _packageCache          = packageCache;
     _output                = output;
     _instanceConfiguration = instanceConfiguration;
     _applicationMap        = applicationMap;
 }
Пример #6
0
 public static IEnumerable <string> Scan(IPackageCache packageCache)
 {
     foreach (var package in packageCache.Packages)
     {
         if (package.PackageVersions.Count(v => v.IsReferenced) > 1)
         {
             yield return
                 ($"{package.Name}: multiple versions in use: {string.Join(", ", package.PackageVersions.Where(v => v.IsReferenced).Select(v => v.Version.ToString()))}");
         }
     }
 }
Пример #7
0
 public SolutionFileProcessor(ISolution solution, IPackageCache packageCache, Func <string, IProject> projectFactoryFunc, Func <string, IPackage> packageFactoryFunc, PackageCacheProcessor packageCacheProcessor, ILogger logger)
 {
     _solution              = solution ?? throw new ArgumentNullException(nameof(solution));
     _packageCache          = packageCache ?? throw new ArgumentNullException(nameof(packageCache));
     _projectFactoryFunc    = projectFactoryFunc ?? throw new ArgumentNullException(nameof(projectFactoryFunc));
     _packageFactoryFunc    = packageFactoryFunc ?? throw new ArgumentNullException(nameof(packageFactoryFunc));
     _packageCacheProcessor = packageCacheProcessor ?? throw new ArgumentNullException(nameof(packageCacheProcessor));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
     if (_solution.Projects == null)
     {
         throw new ArgumentException("Projects collection must be initialized", nameof(solution));
     }
 }
Пример #8
0
 public PackageManager(
     IPackageCache packageCache,
     IPackageLookup packageLookup,
     IPackageLocator packageLocator,
     IPackageGlobalTool packageGlobalTool,
     IPackageRedirector packageRedirector)
 {
     this.packageRedirector = packageRedirector;
     this.m_PackageCache = packageCache;
     _packageLookup = packageLookup;
     this.m_PackageLocator = packageLocator;
     this.m_PackageGlobalTool = packageGlobalTool;
 }
Пример #9
0
        private readonly Regex _rangeVersionRegex = new Regex(@"(\[|\()(([0-9\.,]+))(\]|\))"); // see https://docs.microsoft.com/en-us/nuget/concepts/package-versioning

        public PackageCacheProcessor(Func <string, IPackage> packageFactoryFunc, Func <string, IPackageVersion> packageVersionFactoryFunc, IPackageCache packageCache, ILogger logger)
        {
            _packageFactoryFunc        = packageFactoryFunc ?? throw new ArgumentNullException(nameof(packageFactoryFunc));
            _packageVersionFactoryFunc = packageVersionFactoryFunc ?? throw new ArgumentNullException(nameof(packageVersionFactoryFunc));
            _packageCache = packageCache ?? throw new ArgumentNullException(nameof(packageCache));
            _logger       = logger ?? throw new ArgumentNullException(nameof(logger));
            if (_packageCache.Packages == null)
            {
                throw new ArgumentException($"{nameof(_packageCache.Packages)} was not initialized", nameof(packageCache));
            }
            if (_packageCache.PackagesDictionary == null)
            {
                throw new ArgumentException($"{nameof(_packageCache.PackagesDictionary)} was not initialized", nameof(packageCache));
            }
        }
 public ProjectFileProcessor(Func <string, IProject> projectFactoryFunc, Func <string, IPackage> packageFactoryFunc, ISolution solution, PackageCacheProcessor packageCacheProcessor, AppConfigFileProcessor appConfigFileProcessor, PackagesConfigFileProcessor packagesConfigFileProcessor, IPackageCache packageCache, ILogger logger)
 {
     _projectFactoryFunc          = projectFactoryFunc ?? throw new ArgumentNullException(nameof(projectFactoryFunc));
     _packageFactoryFunc          = packageFactoryFunc ?? throw new ArgumentNullException(nameof(packageFactoryFunc));
     _solution                    = solution ?? throw new ArgumentNullException(nameof(solution));
     _packageCacheProcessor       = packageCacheProcessor ?? throw new ArgumentNullException(nameof(packageCacheProcessor));
     _appConfigFileProcessor      = appConfigFileProcessor ?? throw new ArgumentNullException(nameof(appConfigFileProcessor));
     _packagesConfigFileProcessor = packagesConfigFileProcessor;
     _packageCache                = packageCache ?? throw new ArgumentNullException(nameof(packageCache));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
     if (_packageCache.Packages == null)
     {
         throw new ArgumentException($"{nameof(_packageCache.Packages)} was not initialized", nameof(packageCache));
     }
     if (_packageCache.PackagesDictionary == null)
     {
         throw new ArgumentException($"{nameof(_packageCache.PackagesDictionary)} was not initialized", nameof(packageCache));
     }
 }
Пример #11
0
        public static ICollection <IPackage> GetReferencedPackages(IPackageCache packageCache)
        {
            foreach (var package in packageCache.Packages)
            {
                package.IsReferenced = false;
                foreach (var packageVersion in package.PackageVersions)
                {
                    packageVersion.IsReferenced = false;
                }
            }

            foreach (var package in packageCache.Packages.Where(p => p.ReferencingProjects.Any()))
            {
                package.IsReferenced = package.HasVersions;
                MarkReferences(package);
            }

            return(packageCache.Packages.Where(p => p.IsReferenced).ToList());
        }
Пример #12
0
 public Get(IPackageRepository cacheRepository, IFileSystem fileSystem, IPackageCache packageCache)
 {
     _cacheRepository = cacheRepository;
     OutputFileSystem = fileSystem;
     _packageCache    = packageCache;
 }
 public ProjectBuilder(ISolution solution, IPackageCache packageCache, Action <IProject, string> logErrorAction)
 {
     _solution       = solution;
     _packageCache   = packageCache;
     _logErrorAction = logErrorAction;
 }
 /// <summary>
 /// Creates a new PackageResolutionManager.
 /// </summary>
 /// <param name="console"></param>
 /// <param name="latest"></param>
 /// <param name="cache"> </param>
 public PackageResolutionManager(ILogger console, Boolean latest, IPackageCache cache)
 {
     Console = console;
     Latest  = latest;
     _cache  = cache;
 }
 /// <summary>
 /// Creates a new PackageResolutionManager.
 /// </summary>
 /// <param name="console"></param>
 /// <param name="latest"></param>
 /// <param name="cache"> </param>
 public PackageResolutionManager(ILogger console, Boolean latest, IPackageCache cache)
 {
     Console = console;
     Latest = latest;
     _cache = cache;
 }
Пример #16
0
 public SourcePackageContent(IPackageCache packageCache)
 {
     this.m_PackageCache = packageCache;
 }
Пример #17
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        public override void ExecuteCommand()
        {
            //Probably need some better return code logic here...
            if (Arguments[0] == null) return;
            try
            {
                if (Source.Count == 1 && !NoFeedSpecificCache && !NoCache)
                {
                    _cacheManager = new NuGetCacheManager(Console);
                    _cacheManager.SetFeedSpecificCacheDirectory(_sources[0]);
                }

                if (!NoCache)
                    if (_cacheRepository == null)
                        _cacheRepository = MachineCache.Default;

                //TODO This needs injecting....
                if (_packageCache == null)
                    _packageCache = new MemoryBasedPackageCache(Console);

                _repository = GetRepository();
                _packageResolutionManager = new PackageResolutionManager(Console, Latest, _packageCache);

                //HACK need to inject somehow...
                _packageResolutionManager = _packageResolutionManager ?? new PackageResolutionManager(Console, Latest, new MemoryBasedPackageCache(Console));

                //Working on a package.config
                if (string.IsNullOrEmpty(_baseDirectory))
                    _baseDirectory = Environment.CurrentDirectory;

                var target = Arguments[0] == Path.GetFullPath(Arguments[0]) ? Arguments[0] : Path.GetFullPath(Path.Combine(_baseDirectory, Arguments[0]));
                if (Path.GetFileName(target).Equals(Constants.PackageReferenceFile, StringComparison.OrdinalIgnoreCase))
                {
                    OutputFileSystem = CreateFileSystem(Path.GetPathRoot(target));
                    GetByPackagesConfig(OutputFileSystem, target);
                }
                else
                {
                    OutputFileSystem = CreateFileSystem(Directory.GetParent(target).FullName);
                    GetByDirectoryPath(OutputFileSystem, target);
                }
            }
            catch (Exception e)
            {
                //HACK big catch here, but if anything goes wrong we want to log it and ensure a non-zero exit code...
                throw new CommandLineException(String.Format("GET Failed: {0}",e.Message),e);
            }
        }
Пример #18
0
 public SourcePackageContent(IPackageCache packageCache)
 {
     this.m_PackageCache = packageCache;
 }
Пример #19
0
 public Get(IPackageRepository cacheRepository, IFileSystem fileSystem, IPackageCache packageCache)
 {
     _cacheRepository = cacheRepository;
     OutputFileSystem = fileSystem;
     _packageCache = packageCache;
 }
Пример #20
0
 public Get(IPackageRepositoryFactory packageRepositoryFactory, IPackageSourceProvider sourceProvider, IPackageRepository cacheRepository, IFileSystem fileSystem, IPackageCache packageCache)
     :this(packageRepositoryFactory, sourceProvider)
 {
     _cacheRepository = cacheRepository;
     OutputFileSystem = fileSystem;
     _packageCache = packageCache;
 }
Пример #21
0
 public ReferenceResolver(ISolution solution, IPackageCache packageCache, Action <IContext, string> logWarning)
 {
     _solution     = solution;
     _packageCache = packageCache;
     _logWarning   = logWarning;
 }