public SourceRepository GetSourceRepository(NuGet.IPackageRepository legacyRepo) { V2PackageSource source = new V2PackageSource(@"passed in", () => legacyRepo); IEnumerable <Lazy <INuGetResourceProvider, INuGetResourceProviderMetadata> > providers = Container.GetExports <INuGetResourceProvider, INuGetResourceProviderMetadata>(); Assert.True(providers.Count() > 0); SourceRepository repo = new SourceRepository(source, providers); return(repo); }
public void AddFromRegistry(string keyName, bool isPreUnzipped) { string path = GetRegistryRepositoryPath(keyName, null, _errorHandler); Configuration.PackageSource source; if (isPreUnzipped) { source = new V2PackageSource(path, () => new UnzippedPackageRepository(path)); } else { source = new Configuration.PackageSource(path); } _repositories.Add(_provider.CreateRepository(source)); }
// TODO: clean up public async Task <INuGetResource> Create(SourceRepository source) { V2PackageRepositoryResource repoResource = null; if (!_cache.TryGetValue(source.PackageSource, out repoResource)) { IPackageRepository repo = null; // check if the source passed in contains the repository V2PackageSource v2Source = source.PackageSource as V2PackageSource; if (v2Source != null) { // special case for some of the remaining legacy areas repo = v2Source.CreatePackageRepository(); } else { try { // if it's not in cache, then check if it is V2. if (await V2Utilities.IsV2(source.PackageSource)) { // Get a IPackageRepo object and add it to the cache. repo = V2Utilities.GetV2SourceRepository(source.PackageSource); } } catch (Exception) { // *TODOs:Do tracing and throw apppropriate exception here. Debug.Fail("Unable to create V2 repository on: " + source.PackageSource.Source); } } if (repo != null) { repoResource = new V2PackageRepositoryResource(repo); } // cache regardless of if we are v2 or not _cache.TryAdd(source.PackageSource, repoResource); } return(repoResource); }
public void AddFromRepository(IPackageRepository repo) { var source = new V2PackageSource(repo.Source, () => repo); _repositories.Add(_provider.CreateRepository(source)); }