public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem)
		{
			PathResolverPassedToCreateSharedRepository = pathResolver;
			FileSystemPassedToCreateSharedRepository = fileSystem;
			ConfigSettingsFileSystemPassedToCreateSharedRepository = configSettingsFileSystem;
			return FakeSharedRepository;
		}
예제 #2
0
        public static IPackageRepository GetLocalRepository(IPackagePathResolver pathResolver, IFileSystem nugetPackagesFileSystem)
        {
            IPackageRepository localRepository = new ChocolateyLocalPackageRepository(pathResolver, nugetPackagesFileSystem);
            localRepository.PackageSaveMode = PackageSaveModes.Nupkg;

            return localRepository;
        }
		public ISharedPackageRepository CreateSharedRepository(
			IPackagePathResolver pathResolver,
			IFileSystem fileSystem,
			IFileSystem configSettingsFileSystem)
		{
			return new SharedPackageRepository(pathResolver, fileSystem, configSettingsFileSystem);
		}
예제 #4
0
        public PackageManager(
            IPackageRepository sourceRepository, 
            IPackagePathResolver pathResolver, 
            IFileSystem fileSystem, 
            ISharedPackageRepository localRepository)
        {
            if (sourceRepository == null)
            {
                throw new ArgumentNullException("sourceRepository");
            }
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }
            if (localRepository == null)
            {
                throw new ArgumentNullException("localRepository");
            }

            SourceRepository = sourceRepository;
            DependencyResolver = new DependencyResolverFromRepo(sourceRepository);
            PathResolver = pathResolver;
            FileSystem = fileSystem;
            LocalRepository = localRepository;
            DependencyVersion = DependencyVersion.Lowest;
            CheckDowngrade = true;
        }
		public SharpDevelopProjectManager(IPackageRepository sourceRepository,
			IPackagePathResolver pathResolver,
			IProjectSystem project,
			IPackageRepository localRepository)
			: base(sourceRepository, pathResolver, project, localRepository)
		{
		}
 public Ps1ScaffolderLocator(IPowershellCommandInvoker commandInvoker, IPackageManager packageManager, IPackagePathResolver pathResolver, FileSystem.IFileSystem fileSystem, IScaffoldingConfigStore configStore)
 {
     _commandInvoker = commandInvoker;
     _packageManager = packageManager;
     _pathResolver = pathResolver ?? packageManager.PathResolver;
     _fileSystem = fileSystem;
     _configStore = configStore;
 }
예제 #7
0
 public VsProjectManager(
     VsPackageManager packageManager, 
     IPackagePathResolver pathResolver, 
     IProjectSystem project, 
     IPackageRepository localRepository)
     : base(packageManager, pathResolver, project, localRepository)
 {
     _packageManager = packageManager;
 }
예제 #8
0
        public SharedPackageRepository(IPackagePathResolver resolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem)
            : base(resolver, fileSystem)
        {
            if (configSettingsFileSystem == null)
            {
                throw new ArgumentNullException("configSettingsFileSystem");
            }

            _packageReferenceFile = new PackageReferenceFile(configSettingsFileSystem, Constants.PackageReferenceFile);
        }
        public ServerPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem)
        {
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            _fileSystem = fileSystem;
            _pathResolver = pathResolver;
        }
		public SharpDevelopPackageManager(
			IPackageRepository sourceRepository,
			IProjectSystem projectSystem,
			IFileSystem fileSystem,
			ISharedPackageRepository localRepository,
			IPackagePathResolver pathResolver)
			: base(
				sourceRepository,
				pathResolver,
				fileSystem,
				localRepository)
		{
			this.projectSystem = projectSystem;
			CreateProjectManager();
		}
예제 #11
0
 public PackageFolder(
     string physicalPath,
     bool ignoreFailure,
     Reports reports)
 {
     // We need to help restore operation to ensure case-sensitivity here
     // Turn on the flag to get package ids in accurate casing
     _repository = new PackageRepository(physicalPath, caseSensitivePackagesName: true);
     _fileSystem = new PhysicalFileSystem(physicalPath);
     _pathResolver = new DefaultPackagePathResolver(_fileSystem);
     _reports = reports;
     Source = physicalPath;
     _ignored = false;
     _ignoreFailure = ignoreFailure;
 }
예제 #12
0
        public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, bool enableCaching)
        {
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            FileSystem     = fileSystem;
            PathResolver   = pathResolver;
            _enableCaching = enableCaching;
        }
예제 #13
0
        public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, bool enableCaching)
        {
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            FileSystem = fileSystem;
            PathResolver = pathResolver;
            _enableCaching = enableCaching;
        }
예제 #14
0
        public ServerPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, Func<string, bool, bool> getSetting = null)
        {
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            _fileSystem = fileSystem;
            _pathResolver = pathResolver;
            _getSetting = getSetting ?? GetBooleanAppSetting;
        }
        public ServerPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, Func <string, bool, bool> getSetting = null)
        {
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            _fileSystem   = fileSystem;
            _pathResolver = pathResolver;
            _getSetting   = getSetting ?? GetBooleanAppSetting;
        }
예제 #16
0
 public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, bool enableCaching)
 {
     this._packageCache      = new ConcurrentDictionary <string, PackageCacheEntry>(StringComparer.OrdinalIgnoreCase);
     this._packagePathLookup = new ConcurrentDictionary <PackageName, string>();
     if (pathResolver == null)
     {
         throw new ArgumentNullException("pathResolver");
     }
     if (fileSystem == null)
     {
         throw new ArgumentNullException("fileSystem");
     }
     this.FileSystem     = fileSystem;
     this.PathResolver   = pathResolver;
     this._enableCaching = enableCaching;
 }
        public ServerPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem)
        {
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            _fileSystem   = fileSystem;
            _pathResolver = pathResolver;

            Logger = fileSystem.Logger;
        }
예제 #18
0
        public static LockFileLibrary CreateLockFileLibrary(LockFileLibrary previousLibrary, IPackagePathResolver resolver, IPackage package, string correctedPackageName = null)
        {
            var lockFileLib = new LockFileLibrary();

            // package.Id is read from nuspec and it might be in wrong casing.
            // correctedPackageName should be the package name used by dependency graph and
            // it has the correct casing that runtime needs during dependency resolution.
            lockFileLib.Name = correctedPackageName ?? package.Id;
            lockFileLib.Version = package.Version;
            lockFileLib.Sha512 = File.ReadAllText(resolver.GetHashPath(package.Id, package.Version));

            // If the shas are equal then do nothing
            if (previousLibrary?.Sha512 == lockFileLib.Sha512)
            {
                lockFileLib.Files = previousLibrary.Files;
                lockFileLib.IsServiceable = previousLibrary.IsServiceable;
            }
            else
            {
                lockFileLib.Files = package.GetFiles().Select(p => p.Path).ToList();
                var installPath = resolver.GetInstallPath(package.Id, package.Version);
                foreach (var filePath in lockFileLib.Files)
                {
                    if (!string.Equals(Path.GetExtension(filePath), ".dll", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    var assemblyPath = Path.Combine(installPath, filePath);
                    try
                    {
                        if (IsAssemblyServiceable(assemblyPath))
                        {
                            lockFileLib.IsServiceable = true;
                            break;
                        }
                    }
                    catch
                    {
                        // Just move on to the next file
                    }
                }
            }

            return lockFileLib;
        }
예제 #19
0
        public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IReport report, bool enableCaching)
        {
            if (pathResolver == null)
            {
                throw new ArgumentNullException(nameof(pathResolver));
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException(nameof(fileSystem));
            }

            FileSystem     = fileSystem;
            PathResolver   = pathResolver;
            _enableCaching = enableCaching;
            _report        = report;
        }
예제 #20
0
        public static JObject CreatePackage(IPackage version, string repoRoot, IPackagePathResolver pathResolver)
        {
            var value = new JObject();

            AddProp(value, Properties.Type, new JArray(
                        Types.PackageIdentity.ToString(),
                        Types.PackageDescription.ToString(),
                        Types.PackageDependencies.ToString(),
                        Types.PackageLicensing.ToString()));

            AddProp(value, Properties.PackageId, version.Id);
            AddProp(value, Properties.Version, version.Version.ToString());
            AddProp(value, Properties.Summary, version.Summary);
            AddProp(value, Properties.Description, version.Description);
            AddProp(value, Properties.Authors, String.Join(", ", version.Authors));
            AddProp(value, Properties.Owners, String.Join(", ", version.Owners));
            AddProp(value, Properties.IconUrl, version.IconUrl);
            AddProp(value, Properties.LicenseUrl, version.LicenseUrl);
            AddProp(value, Properties.ProjectUrl, version.ProjectUrl);
            AddProp(value, Properties.Tags, version.Tags == null ? null : version.Tags.Split(' '));
            AddProp(value, Properties.DownloadCount, version.DownloadCount);
            AddProp(value, Properties.Published, version.Published.HasValue ? version.Published.Value.ToString("O", CultureInfo.InvariantCulture) : null);
            AddProp(value, Properties.RequireLicenseAcceptance, version.RequireLicenseAcceptance);
            AddProp(value, Properties.DependencyGroups, version.DependencySets.Select(set => CreateDependencyGroup(set)));

            if (version.MinClientVersion != null)
            {
                AddProp(value, Properties.MinimumClientVersion, version.MinClientVersion.ToString());
            }

            var dsPackage = version as DataServicePackage;

            if (dsPackage != null)
            {
                AddProp(value, Properties.PackageContent, dsPackage.DownloadUrl);
            }
            else if (pathResolver != null)
            {
                AddProp(
                    value,
                    Properties.PackageContent,
                    Path.Combine(repoRoot, pathResolver.GetPackageFileName(version)));
            }

            return(value);
        }
예제 #21
0
        public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IReport report, bool enableCaching)
        {
            if (pathResolver == null)
            {
                throw new ArgumentNullException(nameof(pathResolver));
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException(nameof(fileSystem));
            }

            FileSystem = fileSystem;
            PathResolver = pathResolver;
            _enableCaching = enableCaching;
            _report = report;
        }
        private void EnsureMainAssemblyLoadedInAppDomain(IPackagePathResolver pathResolver, IPackage package, PackageMetadata packageInfo, Guid correlationId)
        {
            var mainAssemblyFileName    = $"{PackageMainAssemblySubFolderPath}{packageInfo.PackageKey}{DefaultAssemblyExtensionLowerCase}";
            var mainAssemblyPackageFile =
                package
                .GetLibFiles()
                .FirstOrDefault(libFile => libFile.Path.Equals(mainAssemblyFileName, StringComparison.InvariantCultureIgnoreCase));

            if (mainAssemblyPackageFile == null)
            {
                this.LogPackageOperation(packageInfo.PackageKey, package.Version, $"No assembly {mainAssemblyFileName} found in {package.GetFullName()}", correlationId);
                return;
            }

            var mainAssemblyFullPath = Path.Combine(pathResolver.GetInstallPath(package), mainAssemblyPackageFile.Path);

            this.LogPackageOperation(packageInfo.PackageKey, package.Version, $"AppDomain.LoadAssembly:'{mainAssemblyFullPath}'", correlationId);
            AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(mainAssemblyFullPath));
        }
예제 #23
0
        public PackageManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem, IPackageRepository localRepository)
        {
            if (sourceRepository == null) {
                throw new ArgumentNullException("sourceRepository");
            }
            if (pathResolver == null) {
                throw new ArgumentNullException("pathResolver");
            }
            if (fileSystem == null) {
                throw new ArgumentNullException("fileSystem");
            }
            if (localRepository == null) {
                throw new ArgumentNullException("localRepository");
            }

            SourceRepository = sourceRepository;
            PathResolver = pathResolver;
            FileSystem = fileSystem;
            LocalRepository = localRepository;
        }
        public void MarkPackageDirectoryForDeletion(IPackage package)
        {
            IFileSystem          repositoryFileSystem = _repositoryFileSystemFactory();
            IPackagePathResolver pathResolver         = _packagePathResolverFactory();
            string packageDirectoryName = pathResolver.GetPackageDirectory(package);

            try
            {
                if (repositoryFileSystem.DirectoryExists(packageDirectoryName))
                {
                    // NOTE: The repository should always be a PhysicalFileSystem, except during testing, so the
                    // .deleteme marker file doesn't get checked into version control
                    repositoryFileSystem.AddFile(packageDirectoryName + DeletionMarkerSuffix, Stream.Null);
                }
            }
            catch (Exception e)
            {
                repositoryFileSystem.Logger.Log(MessageLevel.Warning, String.Format(Resources.VsResources.Warning_FailedToMarkPackageDirectoryForDeletion, packageDirectoryName, e.Message));
            }
        }
예제 #25
0
        private string ResolvePackagePath(IPackagePathResolver defaultResolver,
                                          IEnumerable <IPackagePathResolver> cacheResolvers,
                                          PackageInfo packageInfo)
        {
            string expectedHash = packageInfo.LockFileLibrary.Sha512;

            foreach (var resolver in cacheResolvers)
            {
                var cacheHashFile = resolver.GetHashPath(packageInfo.Id, packageInfo.Version);

                // REVIEW: More efficient compare?
                if (File.Exists(cacheHashFile) &&
                    File.ReadAllText(cacheHashFile) == expectedHash)
                {
                    return(resolver.GetInstallPath(packageInfo.Id, packageInfo.Version));
                }
            }

            return(defaultResolver.GetInstallPath(packageInfo.Id, packageInfo.Version));
        }
예제 #26
0
        internal void InstallPackages(IPackageRepository localRepository,
                                      IFileSystem sharedRepositoryFileSystem,
                                      ISharedPackageRepository sharedPackageRepository,
                                      IPackageRepository sourceRepository,
                                      IPackageConstraintProvider constraintProvider,
                                      IPackagePathResolver pathResolver,
                                      IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(packageManager, pathResolver, project, localRepository)
            {
                ConstraintProvider = constraintProvider
            };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = this;

            bool allowPrerelease = Prerelease;
            var  resolver        = new ActionResolver()
            {
                AllowPrereleaseVersions = allowPrerelease
            };
            var installPackageUtility = new InstallPackageUtility(resolver)
            {
                AllowPrereleaseVersions = allowPrerelease,
                Safe = Safe
            };

            var operations            = installPackageUtility.ResolveActionsForInstallPackage(Id.FirstOrDefault(), Version, new[] { projectManager }, false);
            var userOperationExecutor = new ActionExecutor();

            userOperationExecutor.Execute(operations);
        }
예제 #27
0
        private string ResolvePackagePath(IPackagePathResolver defaultResolver,
                                          IEnumerable <IPackagePathResolver> cacheResolvers,
                                          IPackage package)
        {
            var    defaultHashPath = defaultResolver.GetHashPath(package.Id, package.Version);
            string expectedHash    = null;

            if (File.Exists(defaultHashPath))
            {
                expectedHash = File.ReadAllText(defaultHashPath);
            }
            else if (_globalSettings != null)
            {
                var library = new Library()
                {
                    Name    = package.Id,
                    Version = package.Version
                };

                _globalSettings.PackageHashes.TryGetValue(library, out expectedHash);
            }

            if (string.IsNullOrEmpty(expectedHash))
            {
                return(defaultResolver.GetInstallPath(package.Id, package.Version));
            }

            foreach (var resolver in cacheResolvers)
            {
                var cacheHashFile = resolver.GetHashPath(package.Id, package.Version);

                // REVIEW: More efficient compare?
                if (File.Exists(cacheHashFile) &&
                    File.ReadAllText(cacheHashFile) == expectedHash)
                {
                    return(resolver.GetInstallPath(package.Id, package.Version));
                }
            }

            return(defaultResolver.GetInstallPath(package.Id, package.Version));
        }
예제 #28
0
        private static string ResolvePackagePath(IPackagePathResolver defaultResolver,
                                                 IEnumerable <IPackagePathResolver> cacheResolvers,
                                                 IPackage package)
        {
            var defaultHashPath = defaultResolver.GetHashPath(package.Id, package.Version);

            foreach (var resolver in cacheResolvers)
            {
                var cacheHashFile = resolver.GetHashPath(package.Id, package.Version);

                // REVIEW: More efficient compare?
                if (File.Exists(defaultHashPath) &&
                    File.Exists(cacheHashFile) &&
                    File.ReadAllText(defaultHashPath) == File.ReadAllText(cacheHashFile))
                {
                    return(resolver.GetInstallPath(package.Id, package.Version));
                }
            }

            return(defaultResolver.GetInstallPath(package.Id, package.Version));
        }
예제 #29
0
        internal void UpdatePackages(IPackageRepository localRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem project)
        {
            var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
            {
                ConstraintProvider = constraintProvider
            };

            if (Verbose)
            {
                projectManager.Logger = Console;
            }

            using (sourceRepository.StartOperation(RepositoryOperationNames.Update))
            {
                UpdatePackages(localRepository, projectManager);
            }
        }
예제 #30
0
        internal IEnumerable <PackageDependency> GetReferences(IPackageRepository localRepository,
                                                               IFileSystem sharedRepositoryFileSystem,
                                                               ISharedPackageRepository sharedPackageRepository,
                                                               IPackageRepository sourceRepository,
                                                               IPackageConstraintProvider constraintProvider,
                                                               IPackagePathResolver pathResolver,
                                                               IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
            {
                ConstraintProvider = constraintProvider
            };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = new NugetUpdateTask.VerboseLogger(this);

            using (sourceRepository.StartOperation(RepositoryOperationNames.Update))
            {
                foreach (var package in GetPackages(localRepository))
                {
                    if (localRepository.Exists(package.Id))
                    {
                        if (projectManager.IsInstalled(package))
                        {
                            Log(Level.Debug, "Found installed package {0} version {1}", package.Id, package.Version);
                            yield return(new PackageDependency(package.Id, new VersionSpec(package.Version)));
                        }
                    }
                }
            }
        }
        public ProjectManager(IPackageManager packageManager, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository)
        {
            // !!! TODO: we should get rid of the parameter pathResolver. Use packageManager's path resolver
            // instead.
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            if (localRepository == null)
            {
                throw new ArgumentNullException("localRepository");
            }

            PackageManager              = packageManager;
            Project                     = project;
            PathResolver                = pathResolver;
            LocalRepository             = localRepository;
            _packageReferenceRepository = LocalRepository as IPackageReferenceRepository;
        }
예제 #32
0
        public ProjectManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository)
        {
            if (sourceRepository == null)
            {
                throw new ArgumentNullException("sourceRepository");
            }
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            if (localRepository == null)
            {
                throw new ArgumentNullException("localRepository");
            }

            SourceRepository = sourceRepository;
            Project          = project;
            PathResolver     = pathResolver;
            LocalRepository  = localRepository;
        }
예제 #33
0
        public PackageManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem, IPackageRepository localRepository)
        {
            if (sourceRepository == null)
            {
                throw new ArgumentNullException("sourceRepository");
            }
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }
            if (localRepository == null)
            {
                throw new ArgumentNullException("localRepository");
            }

            SourceRepository = sourceRepository;
            PathResolver     = pathResolver;
            FileSystem       = fileSystem;
            LocalRepository  = localRepository;
        }
		public FakeSharedPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem)
		{
			this.PackagePathResolverPassedToConstructor = pathResolver;
			this.FileSystemPassedToConstructor = fileSystem;
		}
예제 #35
0
 public SharedPackageRepository(IPackagePathResolver resolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem)
     : this(resolver, fileSystem, fileSystem, configSettingsFileSystem)
 {
 }
예제 #36
0
 public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem)
     : this(pathResolver, fileSystem, enableCaching: true)
 {
 }
 public MockSharedRepository(IPackagePathResolver resolver, IFileSystem fileSystem)
     : base(resolver, fileSystem, new MockFileSystem())
 {
 }
예제 #38
0
 /// <summary>
 /// The standard constructor.  We'll just call the base constructor.
 /// </summary>
 /// <param name="sourceRepository"></param>
 /// <param name="pathResolver"></param>
 /// <param name="project"></param>
 /// <param name="localRepository"></param>
 public RockProjectManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository)
     : base(sourceRepository, pathResolver, project, localRepository)
 {
 }
		ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem)
		{
			return packageRepositoryFactory.CreateSharedRepository(pathResolver, fileSystem);
		}
예제 #40
0
 public LucenePackageRepository(IPackagePathResolver packageResolver, IFileSystem fileSystem)
     : base(packageResolver, fileSystem)
 {
 }
예제 #41
0
        internal void UpdatePackages(IPackageRepository localRepository,
                                     IFileSystem sharedRepositoryFileSystem,
                                     ISharedPackageRepository sharedPackageRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(packageManager, pathResolver, project, localRepository)
                                 {
                                     ConstraintProvider = constraintProvider
                                 };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository. 
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = this;

            foreach (var package in GetPackages(localRepository))
            {
                if (localRepository.Exists(package.Id))
                {
                    using (sourceRepository.StartOperation(RepositoryOperationNames.Update, package.Id, mainPackageVersion: null))
                    {
                        try
                        {
                            // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
                            // being considered for an update.
                            bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
                            var resolver = new ActionResolver()
                            {
                                AllowPrereleaseVersions = allowPrerelease
                            };
                            var updateUtility = new UpdateUtility(resolver)
                            {
                                AllowPrereleaseVersions = allowPrerelease,
                                Safe = Safe
                            };

                            var operations = updateUtility.ResolveActionsForUpdate(package.Id, null, new[] { projectManager }, false);
                            var userOperationExecutor = new ActionExecutor();
                            userOperationExecutor.Execute(operations);
                        }
                        catch (InvalidOperationException e)
                        {
                            if (Console.Verbosity == NuGet.Verbosity.Detailed)
                            {
                                Console.WriteWarning(e.ToString());
                            }
                            else
                            {
                                Console.WriteWarning(e.Message);
                            }
                        }
                    }
                }
            }
        }
예제 #42
0
 public UnzippedPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem)
 {
     FileSystem = fileSystem;
     PathResolver = pathResolver;
 }
 public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem)
 {
     return(factory.CreateSharedRepository(pathResolver, fileSystem, configSettingsFileSystem));
 }
 public ChocolateyLocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem)
     : base(pathResolver, fileSystem)
 {
 }
예제 #45
0
 public PackageManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem) :
     this(sourceRepository, pathResolver, fileSystem, new LocalPackageRepository(pathResolver, fileSystem))
 {
 }
예제 #46
0
 public PackageDependencyProvider(string packagesPath)
 {
     _packagesPath        = packagesPath;
     _cacheResolvers      = GetCacheResolvers();
     _packagePathResolver = new DefaultPackagePathResolver(packagesPath);
 }
 public LucenePackageRepository(IPackagePathResolver packageResolver, IFileSystem fileSystem)
     : base(packageResolver, fileSystem)
 {
 }
예제 #48
0
 public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem)
 {
     throw new NotImplementedException();
 }
예제 #49
0
        private string ResolvePackagePath(IPackagePathResolver defaultResolver,
                                          IEnumerable<IPackagePathResolver> cacheResolvers,
                                          PackageInfo packageInfo)
        {
            string expectedHash = packageInfo.LockFileLibrary.Sha;

            foreach (var resolver in cacheResolvers)
            {
                var cacheHashFile = resolver.GetHashPath(packageInfo.Id, packageInfo.Version);

                // REVIEW: More efficient compare?
                if (File.Exists(cacheHashFile) &&
                    File.ReadAllText(cacheHashFile) == expectedHash)
                {
                    return resolver.GetInstallPath(packageInfo.Id, packageInfo.Version);
                }
            }

            return defaultResolver.GetInstallPath(packageInfo.Id, packageInfo.Version);
        }
예제 #50
0
 public PackageManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem) :
     this(sourceRepository, pathResolver, fileSystem, new SharedPackageRepository(pathResolver, fileSystem, fileSystem))
 {
 }
예제 #51
0
        public static IPackageManager GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader, Action <PackageOperationEventArgs> installSuccessAction, Action <PackageOperationEventArgs> uninstallSuccessAction, bool addUninstallHandler)
        {
            IFileSystem          nugetPackagesFileSystem = GetNuGetFileSystem(configuration, nugetLogger);
            IPackagePathResolver pathResolver            = GetPathResolver(configuration, nugetPackagesFileSystem);
            var packageManager = new PackageManager(GetRemoteRepository(configuration, nugetLogger, packageDownloader), pathResolver, nugetPackagesFileSystem, GetLocalRepository(pathResolver, nugetPackagesFileSystem, nugetLogger))
            {
                DependencyVersion = DependencyVersion.Highest,
                Logger            = nugetLogger,
            };

            //NOTE DO NOT EVER use this method - packageManager.PackageInstalling += (s, e) =>
            packageManager.PackageInstalled += (s, e) =>
            {
                var pkg = e.Package;
                "chocolatey".Log().Info(ChocolateyLoggers.Important, "{0}{1} v{2}{3}{4}{5}".format_with(
                                            System.Environment.NewLine,
                                            pkg.Id,
                                            pkg.Version.to_string(),
                                            configuration.Force ? " (forced)" : string.Empty,
                                            pkg.IsApproved ? " [Approved]" : string.Empty,
                                            pkg.PackageTestResultStatus == "Failing" && pkg.IsDownloadCacheAvailable ? " - Likely broken for FOSS users (due to download location changes)" : pkg.PackageTestResultStatus == "Failing" ? " - Possibly broken" : string.Empty
                                            ));

                if (installSuccessAction != null)
                {
                    installSuccessAction.Invoke(e);
                }
            };

            if (addUninstallHandler)
            {
                // NOTE DO NOT EVER use this method, or endless loop - packageManager.PackageUninstalling += (s, e) =>

                packageManager.PackageUninstalled += (s, e) =>
                {
                    IPackage pkg = packageManager.LocalRepository.FindPackage(e.Package.Id, e.Package.Version);
                    if (pkg != null)
                    {
                        // install not actually removed, let's clean it up. This is a bug with nuget, where it reports it removed some package and did NOTHING
                        // this is what happens when you are switching from AllowMultiple to just one and back
                        var chocoPathResolver = packageManager.PathResolver as ChocolateyPackagePathResolver;
                        if (chocoPathResolver != null)
                        {
                            chocoPathResolver.UseSideBySidePaths = !chocoPathResolver.UseSideBySidePaths;

                            // an unfound package folder can cause an endless loop.
                            // look for it and ignore it if doesn't line up with versioning
                            if (nugetPackagesFileSystem.DirectoryExists(chocoPathResolver.GetInstallPath(pkg)))
                            {
                                //todo: This causes an issue with upgrades.
                                // this causes this to be called again, which should then call the uninstallSuccessAction below
                                packageManager.UninstallPackage(pkg, forceRemove: configuration.Force, removeDependencies: false);
                            }

                            chocoPathResolver.UseSideBySidePaths = configuration.AllowMultipleVersions;
                        }
                    }
                    else
                    {
                        if (uninstallSuccessAction != null)
                        {
                            uninstallSuccessAction.Invoke(e);
                        }
                    }
                };
            }

            return(packageManager);
        }
예제 #52
0
 public BetterThanLocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, MSBuildProjectSystem projectSystem)
     : base(pathResolver, fileSystem)
 {
     _projectSystem = projectSystem;
 }
예제 #53
0
 public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem)
     : this(pathResolver, fileSystem, enableCaching : true)
 {
 }
 public PackageAssemblyReferencePathResolver(IPackagePathResolver pathResolver)
 {
     _pathResolver = pathResolver ?? throw new ArgumentNullException(nameof(pathResolver));
 }
예제 #55
0
 public SharedPackageRepository(IPackagePathResolver resolver, IFileSystem fileSystem)
     : base(resolver, fileSystem)
 {
 }
예제 #56
0
        internal void UpdatePackages(IPackageRepository localRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem project)
        {
            var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
                                 {
                                     ConstraintProvider = constraintProvider
                                 };

            if (Verbose)
            {
                projectManager.Logger = Console;
            }

            foreach (var package in GetPackages(localRepository))
            {
                if (localRepository.Exists(package.Id))
                {
                    try
                    {
                        // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
                        // being considered for an update.
                        bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
                        if (Safe)
                        {
                            IVersionSpec safeRange = VersionUtility.GetSafeRange(package.Version);
                            projectManager.UpdatePackageReference(package.Id, safeRange, updateDependencies: true, allowPrereleaseVersions: allowPrerelease);
                        }
                        else
                        {
                            projectManager.UpdatePackageReference(package.Id, version: null, updateDependencies: true, allowPrereleaseVersions: allowPrerelease);
                        }
                    }
                    catch (InvalidOperationException e)
                    {
                        Console.WriteWarning(e.Message);
                    }
                }
            }
        }
예제 #57
0
 public MockSharedRepository(IPackagePathResolver resolver, IFileSystem fileSystem)
     : base(resolver, fileSystem, new MockFileSystem())
 {
 }
 public ChocolateyLocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, bool enableCaching)
     : base(pathResolver, fileSystem, enableCaching)
 {
 }
예제 #59
0
        public IPackageRepository get_local_repository(IPackagePathResolver pathResolver, NuGet.IFileSystem nugetPackagesFileSystem)
        {
            this.Log().Debug(() => "Setting up local repository at '{0}'".format_with(nugetPackagesFileSystem.Root));

            IPackageRepository localRepository = new LocalPackageRepository(pathResolver, nugetPackagesFileSystem);
            localRepository.PackageSaveMode = PackageSaveModes.Nupkg | PackageSaveModes.Nuspec;

            return localRepository;
        }
예제 #60
0
 public SharedPackageRepository(IPackagePathResolver resolver, IFileSystem fileSystem)
     : base(resolver, fileSystem)
 {
 }