public IEnumerable<PackageVerifierIssue> Validate(IPackageRepository packageRepo, IPackage package, IPackageVerifierLogger logger) { if (!package.IsSatellitePackage()) { IEnumerable<string> allXmlFiles = from file in package.GetLibFiles() select file.Path into path where path.EndsWith(".xml", StringComparison.OrdinalIgnoreCase) select path; foreach (IPackageFile current in package.GetLibFiles()) { string assemblyPath = current.Path; // TODO: Does this need to check for just managed code? if (assemblyPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { string docFilePath = Path.ChangeExtension(assemblyPath, ".xml"); if (!allXmlFiles.Contains(docFilePath, StringComparer.OrdinalIgnoreCase)) { yield return PackageIssueFactory.AssemblyHasNoDocFile(assemblyPath); } } } } yield break; }
internal void InstallPackage(IPackageRepository repository, Project project, string packageId, SemanticVersion version, bool ignoreDependencies) { if (project == null) { throw new ArgumentNullException("project"); } IVsPackageManager packageManager = _packageManagerFactory.CreatePackageManager(repository, useFallbackForDependencies: false, addToRecent: false); IProjectManager projectManager = packageManager.GetProjectManager(project); EventHandler<PackageOperationEventArgs> installedHandler = (sender, e) => { _scriptExecutor.ExecuteInitScript(e.InstallPath, e.Package, NullLogger.Instance); }; EventHandler<PackageOperationEventArgs> addedHandler = (sender, e) => { _scriptExecutor.ExecuteScript(e.InstallPath, PowerShellScripts.Install, e.Package, project, NullLogger.Instance); }; try { projectManager.PackageReferenceAdded += addedHandler; packageManager.PackageInstalled += installedHandler; packageManager.InstallPackage(projectManager, packageId, version, ignoreDependencies, allowPrereleaseVersions: true, logger: NullLogger.Instance); } finally { projectManager.PackageReferenceAdded -= addedHandler; packageManager.PackageInstalled -= installedHandler; } }
public InstallWalker(IPackageRepository localRepository, IPackageRepository sourceRepository, IPackageConstraintProvider constraintProvider, FrameworkName targetFramework, ILogger logger, bool ignoreDependencies, bool allowPrereleaseVersions) : base(targetFramework) { if (sourceRepository == null) { throw new ArgumentNullException("sourceRepository"); } if (localRepository == null) { throw new ArgumentNullException("localRepository"); } if (logger == null) { throw new ArgumentNullException("logger"); } Repository = localRepository; Logger = logger; SourceRepository = sourceRepository; _ignoreDependencies = ignoreDependencies; ConstraintProvider = constraintProvider; _operations = new OperationLookup(); _allowPrereleaseVersions = allowPrereleaseVersions; }
public WebProjectManager(IPackageRepository source, string siteRoot, IWebMatrixHost host) { if (source == null) { throw new ArgumentNullException("source"); } if (String.IsNullOrEmpty(siteRoot)) { throw new ArgumentException("siteRoot"); } _siteRoot = siteRoot; string webRepositoryDirectory = GetWebRepositoryDirectory(siteRoot); Logger = new ErrorLogger(host); var project = new WebProjectSystem(siteRoot); project.Logger = Logger; _projectManager = new ProjectManager(sourceRepository: source, pathResolver: new DefaultPackagePathResolver(webRepositoryDirectory), localRepository: PackageRepositoryFactory.Default.CreateRepository(webRepositoryDirectory), project: project); }
public override void ExecuteCommand() { if (string.IsNullOrEmpty(Directory)) { Directory = Environment.CurrentDirectory; } if (_repository == null) { _repository = AggregateRepositoryHelper.CreateAggregateRepositoryFromSources(RepositoryFactory, SourceProvider, Source); } var packageFiles = _fileSystem.GetFiles(Directory, "packages.config", true).ToList(); Console.WriteLine("Processing : {0} files.",packageFiles.Count); Parallel.ForEach(packageFiles, packageFile => { Console.WriteLine("\t{0}", packageFile); var newReferences = new List<PackageReference>(); var packageFileDetails = new PackageReferenceFile(_fileSystem, packageFile); foreach (var packageReference in packageFileDetails.GetPackageReferences()) { Console.WriteLine("\t\t{0}",packageReference.ToString()); var exists = _repository.FindPackage(packageReference.Id, packageReference.Version); if (exists != null) { Console.WriteLine("\t\t\tExists, not changing."); newReferences.Add(packageReference); } else { var package = _repository.FindPackagesById(packageReference.Id).FirstOrDefault(); if (package == null) { Console.WriteLine("\t\t\tNot found, no change."); newReferences.Add(packageReference); } else { var newReference = new PackageReference(package.Id, package.Version, new VersionSpec(), new FrameworkName(".NET Framework, Version=4.0"), false); Console.WriteLine("\t\t\tUpdated to {0}", newReference.ToString()); newReferences.Add(newReference); } } } //TODO Clear the file (must be an easier way). Console.WriteLine("Clearing existing file..."); foreach (var packageReference in packageFileDetails.GetPackageReferences()) { packageFileDetails.DeleteEntry(packageReference.Id, packageReference.Version); } //Add the new references. Console.WriteLine("Adding new references..."); foreach (var packageReference in newReferences) { packageFileDetails.AddEntry(packageReference.Id, packageReference.Version); } }); }
public UpdatedPackages( IQueryable<IPackage> installedPackages, IPackageRepository aggregrateRepository) { this.installedPackages = installedPackages; this.sourceRepository = aggregrateRepository; }
internal PackageRestoreManager( DTE dte, ISolutionManager solutionManager, IFileSystemProvider fileSystemProvider, IPackageRepositoryFactory packageRepositoryFactory, IVsPackageSourceProvider packageSourceProvider, IVsPackageManagerFactory packageManagerFactory, IVsPackageInstallerEvents packageInstallerEvents, IPackageRepository localCacheRepository, IVsThreadedWaitDialogFactory waitDialogFactory, ISettings settings) { Debug.Assert(solutionManager != null); _dte = dte; _fileSystemProvider = fileSystemProvider; _solutionManager = solutionManager; _packageRepositoryFactory = packageRepositoryFactory; _packageSourceProvider = packageSourceProvider; _waitDialogFactory = waitDialogFactory; _packageManagerFactory = packageManagerFactory; _localCacheRepository = localCacheRepository; _settings = settings; _solutionManager.ProjectAdded += OnProjectAdded; _solutionManager.SolutionOpened += OnSolutionOpenedOrClosed; _solutionManager.SolutionClosed += OnSolutionOpenedOrClosed; packageInstallerEvents.PackageReferenceAdded += OnPackageReferenceAdded; }
protected internal InstallCommand(IPackageRepository cacheRepository) : base(cacheRepository) { // On mono, parallel builds are broken for some reason. See https://gist.github.com/4201936 for the errors // That are thrown. DisableParallelProcessing = EnvironmentUtility.IsMonoRuntime; }
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 UninstallWalker(IPackageRepository repository, IDependentsResolver dependentsResolver, FrameworkName targetFramework, ILogger logger, bool removeDependencies, bool forceRemove) : base(targetFramework) { if (dependentsResolver == null) { throw new ArgumentNullException("dependentsResolver"); } if (repository == null) { throw new ArgumentNullException("repository"); } if (logger == null) { throw new ArgumentNullException("logger"); } Logger = logger; Repository = repository; DependentsResolver = dependentsResolver; Force = forceRemove; ThrowOnConflicts = true; Operations = new Stack<PackageOperation>(); _removeDependencies = removeDependencies; }
protected internal InstallCommand( IPackageRepositoryFactory packageRepositoryFactory, IPackageSourceProvider sourceProvider, ISettings configSettings, IPackageRepository cacheRepository) { if (packageRepositoryFactory == null) { throw new ArgumentNullException("packageRepositoryFactory"); } if (sourceProvider == null) { throw new ArgumentNullException("sourceProvider"); } if (configSettings == null) { throw new ArgumentNullException("configSettings"); } RepositoryFactory = packageRepositoryFactory; SourceProvider = sourceProvider; _cacheRepository = cacheRepository; _configSettings = configSettings; }
public DependentsWalker(IPackageRepository repository) { if (repository == null) { throw new ArgumentNullException("repository"); } Repository = repository; }
public TestGetCommand(IPackageRepositoryFactory packageRepositoryFactory, IPackageSourceProvider sourceProvider, IPackageRepository cacheRepository, Mock<MockFileSystem> fileSystem) : base(cacheRepository, fileSystem.Object, new MemoryBasedPackageCache(new Mock<IConsole>().Object)) { RepositoryFactory = packageRepositoryFactory; SourceProvider = sourceProvider; mockFileSystem = fileSystem; }
public override IPackageManagementProject GetActiveProject(IPackageRepository sourceRepository) { if (ExceptionToThrowWhenGetActiveProjectCalled != null) { throw ExceptionToThrowWhenGetActiveProjectCalled; } return base.GetActiveProject(sourceRepository); }
protected PackagesProviderBase( IPackageRepository localRepository, ResourceDictionary resources, ProviderServices providerServices, IProgressProvider progressProvider, ISolutionManager solutionManager) { if (resources == null) { throw new ArgumentNullException("resources"); } if (providerServices == null) { throw new ArgumentNullException("providerServices"); } if (solutionManager == null) { throw new ArgumentNullException("solutionManager"); } _localRepository = localRepository; _providerServices = providerServices; _progressProvider = progressProvider; _solutionManager = solutionManager; _resources = resources; _outputConsole = new Lazy<IConsole>(() => providerServices.OutputConsoleProvider.CreateOutputConsole(requirePowerShellHost: false)); }
public UpdateAllPackagesInSolution( IPackageManagementSolution solution, IPackageRepository sourceRepository) { this.solution = solution; this.sourceRepository = sourceRepository; }
public CachedZipPackage(IPackageRepository source, IFile packageFile, IDirectory cacheDirectoryPath, IEnumerable<IExportBuilder> builders) : base(packageFile) { Source = source; _cacheDirectoryPathPath = cacheDirectoryPath; _builders = builders; }
public InstallWalker(IPackageRepository localRepository, IDependencyResolver2 dependencyResolver, IPackageConstraintProvider constraintProvider, FrameworkName targetFramework, ILogger logger, bool ignoreDependencies, bool allowPrereleaseVersions, DependencyVersion dependencyVersion) : base(targetFramework) { if (dependencyResolver == null) { throw new ArgumentNullException("dependencyResolver"); } if (localRepository == null) { throw new ArgumentNullException("localRepository"); } if (logger == null) { throw new ArgumentNullException("logger"); } Repository = localRepository; Logger = logger; DependencyResolver = dependencyResolver; _ignoreDependencies = ignoreDependencies; ConstraintProvider = constraintProvider; _operations = new OperationLookup(); _allowPrereleaseVersions = allowPrereleaseVersions; DependencyVersion = dependencyVersion; CheckDowngrade = true; }
/// <summary> /// Installs the specified packages and the dependencies needed to run them /// </summary> /// <param name="packages">The list of packages to install</param> /// <returns>The list of paths of the installed assemblies</returns> public IEnumerable<string> InstallAssemblies(IEnumerable<NuGetPackageInfo> packages) { if (packageSource == null) { throw new ArgumentNullException("packageSource"); } if (!packages.Any()) { this.logger.LogInfo(RoslynResources.NoAnalyzerPackages); return Enumerable.Empty<string>(); } this.logger.LogInfo(RoslynResources.InstallingPackages); this.logger.LogDebug(RoslynResources.CreatingRepository, this.packageSource); this.remoteRepository = PackageRepositoryFactory.Default.CreateRepository(this.packageSource); // Create the local NuGet cache Directory.CreateDirectory(this.localCacheDirectory); this.manager = new PackageManager(remoteRepository, this.localCacheDirectory); this.manager.Logger = new NuGetLoggerAdapter(this.logger); ISet<string> assemblyPaths = new HashSet<string>(); foreach(NuGetPackageInfo package in packages) { ProcessPackage(package, assemblyPaths); } this.logger.LogInfo(RoslynResources.PackagesInstalled); return assemblyPaths; }
public IPackageConstraintProvider GetConstraintProvider(IPackageRepository repository) { if (HasSingleProjectSelected()) { return GetSingleProjectSelected(repository).ConstraintProvider; } return NullConstraintProvider.Instance; }
public IUpdatePackageActions CreateUpdatePackageInAllProjects( PackageReference packageReference, IPackageManagementSolution solution, IPackageRepository sourceRepository) { return new UpdatePackageInAllProjects(packageReference, solution, sourceRepository); }
public IEnumerable<PackageOperationResult> AddSystemPackage(PackageRequest packageToAdd, IEnumerable<IPackageRepository> sourceRepositories, IPackageRepository systemRepository, PackageAddOptions options = PackageAddOptions.Default) { return CopyPackageCore(sourceRepositories, new[] { systemRepository }, ToDescriptor(packageToAdd, options), x => true); }
bool TryInitialize() { try { _dte = SiteManager.GetGlobalService<DTE>(); _running = _dte != null; } catch { _running = false; } if (!_running) return false; // TODO: seen in the wild, _dte.Solution is null (?), need to schedule and restart initialization for those scenarios. _solution = new DteSolution(_dte.Solution); _solution.ProjectChanged += HandleProjectChange; var environment = ServiceLocator.GetService<IEnvironment>(); _packageManager = ServiceLocator.GetService<IPackageManager>(); _assembliesChanged = new EventWaitHandle(false, EventResetMode.AutoReset, System.Diagnostics.Process.GetCurrentProcess().Id + ASSEMBLY_NOTIFY); _rootDirectory = environment.DescriptorFile.Parent; _projectRepository = environment.ProjectRepository; RegisterFileListener(); RefreshProjects(); _timer = new Timer(_ => RefreshProjects(), null, Timeout.Infinite, Timeout.Infinite); return true; }
public UpdatedPackages( IPackageManagementProject project, IPackageRepository aggregateRepository) : this(project.GetPackages(), aggregateRepository) { }
public UncompressedPackage(IPackageRepository source, IFile originalPackageFile, IDirectory wrapCacheDirectory) { Check.NotNull(source, "source"); if (originalPackageFile == null || originalPackageFile.Exists == false) { IsValid = false; return; } _originalPackageFile = originalPackageFile; BaseDirectory = wrapCacheDirectory; // get the descriptor file inside the package Source = source; var wrapDescriptor = wrapCacheDirectory.Files("*.wrapdesc").SingleOrDefault(); if (wrapDescriptor == null) { IsValid = false; return; } var versionFile = wrapCacheDirectory.GetFile("version"); _descriptor = new PackageDescriptorReader().Read(wrapDescriptor); _semver = _descriptor.SemanticVersion ?? _descriptor.Version.ToSemVer(); if (_semver == null) _semver = versionFile.Exists ? versionFile.ReadString().ToSemVer() : null; IsValid = string.IsNullOrEmpty(Name) == false && _semver != null; if (IsValid) Identifier = new PackageIdentifier(Name, _semver); }
public MirrorCommand(IPackageSourceProvider packageSourceProvider, ISettings settings, IPackageRepositoryFactory packageRepositoryFactory) { SourceProvider = packageSourceProvider; Settings = settings; RepositoryFactory = packageRepositoryFactory; _cacheRepository = MachineCache.Default; }
public static bool IsSatellitePackage( IPackage package, IPackageRepository repository, FrameworkName targetFramework, out IPackage runtimePackage) { // A satellite package has the following properties: // 1) A package suffix that matches the package's language, with a dot preceding it // 2) A dependency on the package with the same Id minus the language suffix // 3) The dependency can be found by Id in the repository (as its path is needed for installation) // Example: foo.ja-jp, with a dependency on foo runtimePackage = null; if (package.IsSatellitePackage()) { string runtimePackageId = package.Id.Substring(0, package.Id.Length - (package.Language.Length + 1)); PackageDependency dependency = package.FindDependency(runtimePackageId, targetFramework); if (dependency != null) { runtimePackage = repository.FindPackage(runtimePackageId, versionSpec: dependency.VersionSpec, allowPrereleaseVersions: true, allowUnlisted: true); } } return runtimePackage != null; }
IEnumerable<IPackage> GetUpdatedPackages( IPackageRepository sourceRepository, IEnumerable<IPackage> localPackages, bool includePrelease) { return sourceRepository.GetUpdates(localPackages, includePrelease, false); }
public NuGetBrowser(IEnumerable<string> repositories) { var reposToUse = new List<IPackageRepository>(); reposToUse.AddRange(repositories.ToList().Select(r => PackageRepositoryFactory.Default.CreateRepository(r))); repository = new AggregateRepository(reposToUse); }
public NugetService(Solution solution) { //_defaultPackageSource = new PackageSource(NuGetConstants.DefaultFeedUrl); var factory = new PackageRepositoryFactory(); _remoteRepository = factory.CreateRepository(GalleryUrl); _localRepository = factory.CreateRepository(solution.PackagesFolder()); _sourceRepository = new AggregateRepository(new[] { _remoteRepository, _localRepository }); _fileSystem = new PhysicalFileSystem(solution.PackagesFolder()); _pathResolver = new DefaultPackagePathResolver(_fileSystem); _console = new Console(); _packageManager = new PackageManager(_sourceRepository, _pathResolver, _fileSystem, _localRepository){ Logger = _console }; _packages = new Cache<NugetDependency, IPackage>(dep => { Install(dep); return _sourceRepository.FindPackage(dep.Name, dep.Version); }); }
public void InstallPackage(IPackageRepository repository, Project project, string packageId, string version, bool ignoreDependencies, bool skipAssemblyReferences) { // It would be really difficult for anyone to use this method throw new NotSupportedException(); }
IQueryable <IPackage> GetInstalledPackages(IPackageRepository aggregateRepository) { return(selectedProjects.GetPackages(aggregateRepository)); }
public Walker(List<IPackage> packages, FrameworkName targetFramework) : base(targetFramework) { _packages = packages; _repository = new ReadOnlyPackageRepository(packages.ToList()); }
public ConflictResult(IPackage conflictingPackage, IPackageRepository repository, IDependentsResolver resolver) { Package = conflictingPackage; Repository = repository; DependentsResolver = resolver; }
public MockVsPackageManager(IPackageRepository sourceRepository) : base(new Mock <ISolutionManager>().Object, sourceRepository, new Mock <IFileSystemProvider>().Object, new Mock <IFileSystem>().Object, new Mock <ISharedPackageRepository>().Object, new Mock <IDeleteOnRestartManager>().Object, new Mock <VsPackageInstallerEvents>().Object) { }
public void InstallPackage(IPackageRepository repository, Project project, string packageId, string version, bool ignoreDependencies, bool skipAssemblyReferences) { InstalledPackages.Add(packageId); }
public PackageFromRepository(IPackage package, IPackageRepository repository) { this.package = package; this.Repository = repository; }
public void AddFromRepository(IPackageRepository repo) { var source = new V2PackageSource(repo.Source, () => repo); _repositories.Add(_provider.CreateRepository(source)); }
private void AddFiles(PackageBuilder builder, string itemType, string targetFolder) { // Skip files that are added by dependency packages var references = PackageReferenceFile.CreateFromProject(_project.FullPath).GetPackageReferences(); IPackageRepository repository = GetPackagesRepository(); string projectName = Path.GetFileNameWithoutExtension(_project.FullPath); var contentFilesInDependencies = new List<IPackageFile>(); if (references.Any() && repository != null) { contentFilesInDependencies = references.Select(reference => repository.FindPackage(reference.Id, reference.Version)) .Where(a => a != null) .SelectMany(a => a.GetContentFiles()) .ToList(); } // Get the content files from the project foreach (var item in _project.GetItems(itemType)) { string fullPath = item.GetMetadataValue("FullPath"); if (_excludeFiles.Contains(Path.GetFileName(fullPath))) { continue; } string targetFilePath = GetTargetPath(item); if (!File.Exists(fullPath)) { Logger.Log(MessageLevel.Warning, LocalizedResourceManager.GetString("Warning_FileDoesNotExist"), targetFilePath); continue; } // Skip target file paths containing msbuild variables since we do not offer a way to install files with variable paths. // These are show up in shared files found in universal apps. if (targetFilePath.IndexOf("$(MSBuild", StringComparison.OrdinalIgnoreCase) > -1) { Logger.Log(MessageLevel.Warning, LocalizedResourceManager.GetString("Warning_UnresolvedFilePath"), targetFilePath); continue; } // if IncludeReferencedProjects is true and we are adding source files, // add projectName as part of the target to avoid file conflicts. string targetPath = IncludeReferencedProjects && itemType == SourcesItemType ? Path.Combine(targetFolder, projectName, targetFilePath) : Path.Combine(targetFolder, targetFilePath); // Check that file is added by dependency IPackageFile targetFile = contentFilesInDependencies.Find(a => a.Path.Equals(targetPath, StringComparison.OrdinalIgnoreCase)); if (targetFile != null) { // Compare contents as well var isEqual = ContentEquals(targetFile, fullPath); if (isEqual) { Logger.Log(MessageLevel.Info, LocalizedResourceManager.GetString("PackageCommandFileFromDependencyIsNotChanged"), targetFilePath); continue; } Logger.Log(MessageLevel.Info, LocalizedResourceManager.GetString("PackageCommandFileFromDependencyIsChanged"), targetFilePath); } var packageFile = new PhysicalPackageFile { SourcePath = fullPath, TargetPath = targetPath }; AddFileToBuilder(builder, packageFile); } }
IEnumerable <ICommandOutput> ValidateInputs() { // TODO: HACK HACK HACK var namedRepository = Remotes.PublishRepositories(Remote).SelectMany(_ => _).FirstOrDefault(); if (namedRepository == null) { yield return(new UnknownRemoteName(Remote)); foreach (var _ in HintRemoteRepositories()) { yield return(_); } yield break; } if ((Username != null && Password == null) || (Username == null && Password != null)) { yield return(new IncompleteCredentials()); yield break; } bool hasAuth = Username != null && Password != null; if (hasAuth) { _credentials = new NetworkCredential(Username, Password); } _authenticationSupport = namedRepository.Feature <ISupportAuthentication>(); if (hasAuth && _authenticationSupport == null) { yield return(new RemoteAuthenticatioNotSupported(namedRepository)); yield break; } _authenticationSupport = _authenticationSupport ?? new NullAuthentication(); //_repositories = namedRepository. _remoteRepository = namedRepository; var publishingRepo = _remoteRepository.Feature <ISupportPublishing>(); if (publishingRepo == null) { yield return(new Error("Repository '{0}' doesn't support publishing.", namedRepository.Name)); yield break; } if (Path != null) { var packageFile = FileSystem.GetFile(Path); if (!packageFile.Exists) { yield return(new FileNotFound(Path)); yield break; } _packageStream = packageFile.OpenRead; _packageFileName = packageFile.Name; // TODO: This looks iffy at best var package = new ZipFilePackage(packageFile); _packageName = package.Name; _packageVersion = package.SemanticVersion; } else if (Name != null) { // get latest version of the Named package if (!HostEnvironment.CurrentDirectoryRepository.PackagesByName.Contains(Name)) { yield return(new Error("No package named '{0}' was found.", Name)); yield break; } var packageToCopy = HostEnvironment.CurrentDirectoryRepository.PackagesByName[Name].OrderByDescending(x => x.SemanticVersion).First(); _packageStream = () => packageToCopy.Load().OpenStream(); _packageFileName = packageToCopy.FullName + ".wrap"; _packageName = packageToCopy.Name; _packageVersion = packageToCopy.SemanticVersion; } else { yield return(new Error("Please specify either a file path using the -Path input, or a name using -Name.")); } }
public NullProjectManager(IPackageManager packageManager) { _localRepository = new VirtualRepository(repo: null); _project = new NullProjectSystem(); PackageManager = packageManager; }
/// <summary> /// Register this repository as a default one, which will be used to infer /// package references without reference to specific repository. /// </summary> /// <remarks> /// Default repositories must be specified and completely initialized by the /// implementer of pppm before any other uppm operations take place. /// </remarks> public static void RegisterDefaultRepository(this IPackageRepository repository) { DefaultRepositories.UpdateGeneric(repository.Url, repository); PresentRepositories.UpdateGeneric(repository.Url, repository); }
public UpdatePackageCommandHandler(IPackageRepository repo, IEventMediator mediator) { this.repo = repo; this.mediator = mediator; }
internal static void RegisterRepository(this IPackageRepository repository) { PresentRepositories.UpdateGeneric(repository.Url, repository); }
public UpdatePackages(string updateUrl) { _packageRepository = PackageRepositoryFactory.Default.CreateRepository(updateUrl); }
/// <summary> /// Tries to convert a <see cref="PartialPackageReference"/> into a <see cref="CompletePackageReference"/> /// one in the context of an <see cref="IPackageRepository"/> and a provided collection of available packages. /// </summary> /// <param name="repository">Target repository</param> /// <param name="packages">Collection of all available packages supplied by the repository</param> /// <param name="incomplete">The source <see cref="PartialPackageReference"/></param> /// <param name="complete">The output <see cref="CompletePackageReference"/> when found or null when there's no match</param> /// <returns>Whether infering found a valid package or not</returns> public static bool TryInferPackageReferenceFromCollection( this IPackageRepository repository, IEnumerable <CompletePackageReference> packages, PartialPackageReference incomplete, out CompletePackageReference complete) { complete = null; if (incomplete?.Name == null) { return(false); } // should the pack be in this repository? if (!string.IsNullOrWhiteSpace(incomplete.RepositoryUrl) && !incomplete.RepositoryUrl.EqualsCaseless(repository.Url)) { return(false); } // is the pack present in this repository? var candidates = packages.Where(p => p.Name.EqualsCaseless(incomplete.Name)).ToList(); if (candidates.Count == 0) { return(false); } // if special version just check for string equality if (incomplete.IsSpecialVersion) { var candidate = candidates.FirstOrDefault(p => p.Version.EqualsCaseless(incomplete.Version)); if (candidate != null) { complete = candidate; return(true); } } // if no version specified or explicitly "latest" is speciofied then get the latest var getlatest = incomplete.Version == null || incomplete.IsLatest; if (getlatest) { // is a pack explicitly labeled "latest" exists already? var candidate = candidates.FirstOrDefault(p => p.IsLatest); if (candidate != null) { complete = candidate; return(true); } // if not try to get the one with the highest semantical version var version = new PppmVersion(0, 0, 0, 0); foreach (var cand in candidates) { if (cand.IsSemanticalVersion(out var semversion) && version < semversion) { version = semversion; candidate = cand; } } if (candidate != null) { complete = candidate; return(true); } // pack has only special versions or no versions at all return(false); } // if an optionally partial semantic version is explicitly specified if (incomplete.IsSemanticalVersion(out var insemver)) { // get the latest semantic version inside the specified version scope var candidate = candidates.Where(p => { var valid = p.IsSemanticalVersion(out var psemver); if (!valid) { return(false); } for (int i = 0; i < (int)insemver.Scope + 1; i++) { valid = psemver.Components[i] == insemver.Components[i]; } return(valid); }) .OrderByDescending(p => p.IsSemanticalVersion(out var psemver) ? psemver : new PppmVersion(0, 0, 0, 0)) .FirstOrDefault(); if (candidate != null) { complete = candidate; return(true); } } return(false); }
IPackage matchPackage(IPackageRepository packageRepository, string id, IVersionSpec version) { return(packageRepository.FindPackagesById(id).FirstOrDefault(x => VersionComparer.Matches(version, x.Version))); }
public RepositoryPackages(IPackageRepository repository, IEnumerable <PackageFoundResult> packages) // : base(" - {0} (available: {1})", result.Name, result.Packages.Select(x => x.Version + (x.Nuked ? " [nuked]" : string.Empty)).JoinString(", ")) { Repository = repository; Packages = packages; }
public static IPackage FindPackage(this IPackageRepository repository, string packageId, SemanticVersion version) { // Default allow pre release versions to true here because the caller typically wants to find all packages in this scenario for e.g when checking if a // a package is already installed in the local repository. The same applies to allowUnlisted. return(FindPackage(repository, packageId, version, NullConstraintProvider.Instance, allowPrereleaseVersions: true, allowUnlisted: true)); }
public PackageRepository(string apiKey) { _apiKey = apiKey; _repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2"); _server = new PackageServer("https://nuget.org", "chromypack"); }
public static bool TryFindPackage(this IPackageRepository repository, string packageId, SemanticVersion version, out IPackage package) { package = repository.FindPackage(packageId, version); return(package != null); }
public static IPackage FindPackage(this IPackageRepository repository, string packageId, SemanticVersion version, bool allowPrereleaseVersions, bool allowUnlisted) { return(FindPackage(repository, packageId, version, NullConstraintProvider.Instance, allowPrereleaseVersions, allowUnlisted)); }
public static bool Exists(this IPackageRepository repository, string packageId) { return(Exists(repository, packageId, version: null)); }
public static IPackage FindPackage(this IPackageRepository repository, string packageId) { return(repository.FindPackage(packageId, version: null)); }
public static bool Exists(this IPackageRepository repository, IPackageMetadata package) { return(repository.Exists(package.Id, package.Version)); }
public static IPackage ResolveDependency(this IPackageRepository repository, PackageDependency dependency, bool allowPrereleaseVersions, bool preferListedPackages) { return(ResolveDependency(repository, dependency, constraintProvider: null, allowPrereleaseVersions: allowPrereleaseVersions, preferListedPackages: preferListedPackages)); }
public static IPackage FindPackage( this IPackageRepository repository, string packageId, SemanticVersion version, IPackageConstraintProvider constraintProvider, bool allowPrereleaseVersions, bool allowUnlisted) { if (repository == null) { throw new ArgumentNullException("repository"); } if (packageId == null) { throw new ArgumentNullException("packageId"); } // if an explicit version is specified, disregard the 'allowUnlisted' argument // and always allow unlisted packages. if (version != null) { allowUnlisted = true; } else if (!allowUnlisted && (constraintProvider == null || constraintProvider == NullConstraintProvider.Instance)) { var packageLatestLookup = repository as ILatestPackageLookup; if (packageLatestLookup != null) { IPackage package; if (packageLatestLookup.TryFindLatestPackageById(packageId, allowPrereleaseVersions, out package)) { return(package); } } } // If the repository implements it's own lookup then use that instead. // This is an optimization that we use so we don't have to enumerate packages for // sources that don't need to. var packageLookup = repository as IPackageLookup; if (packageLookup != null && version != null) { return(packageLookup.FindPackage(packageId, version)); } IEnumerable <IPackage> packages = repository.FindPackagesById(packageId); packages = packages.ToList() .OrderByDescending(p => p.Version); if (!allowUnlisted) { packages = packages.Where(PackageExtensions.IsListed); } if (version != null) { packages = packages.Where(p => p.Version == version); } else if (constraintProvider != null) { packages = DependencyResolveUtility.FilterPackagesByConstraints(constraintProvider, packages, packageId, allowPrereleaseVersions); } return(packages.FirstOrDefault()); }
public static IQueryable <IPackage> Search(this IPackageRepository repository, string searchTerm, bool allowPrereleaseVersions) { return(Search(repository, searchTerm, targetFrameworks: Enumerable.Empty <string>(), allowPrereleaseVersions: allowPrereleaseVersions)); }
public PackageDetails GetPackageDetails(IPackageRepository packageRepository, IPackage package, bool allowPrereleaseVersions) { Argument.IsNotNull(() => package); return(_packageDetailsCache.GetFromCacheOrFetch(package.GetKeyForCache(allowPrereleaseVersions), () => new PackageDetails(package, packageRepository.FindPackagesById(package.Id).Select(p => p.Version.ToString()).Where(p => allowPrereleaseVersions || !p.Contains("-"))))); }
public UserPackageApiController() { _packageRepository = FtUnityMapper.GetInstance <IPackageRepository>(); }