public Stream Download(PackageKey key) { var fullPath = Path.Combine(RootPath, key.GetFileName()); if (!File.Exists(fullPath)) { throw new FileNotFoundException("package not found"); } return(File.OpenRead(fullPath)); }
public PackageManifest GetManifest(PackageKey key, NuGet.Frameworks.NuGetFramework projectFramework) { if (key.Framework != null) { var fullPath = Path.Combine(RootPath, key.GetFileName()); if (!File.Exists(fullPath)) { throw new FileNotFoundException("package not found"); } using (IPackageReader reader = _packageReaderFactory.Get(RepositoryType.Pundit, File.OpenRead(fullPath))) return(reader.ReadManifest()); } // From here on, we resolve packages that come from a NuGet package and therefore, have no FW var filePattern = key.GetNoFrameworkFileName(); var results = new DirectoryInfo(RootPath).GetFiles(filePattern).ToArray(); if (results.Length == 0) { return(null); } var matches = 0; foreach (var info in results) { var tempKey = PackageExtensions.GetPackageKeyFromFileName(info.Name); var nearestFw = NuGet.Frameworks.NuGetFrameworkUtility.GetNearest(new[] { new FakedFrameworkGroup(tempKey.Framework) }, projectFramework); if (nearestFw.TargetFramework.GetShortFolderName() == tempKey.Framework) { matches++; } } if (matches != 1) { throw new NotSupportedException("Error, 0 or more than 1 package found matching the framework."); } using (IPackageReader reader = _packageReaderFactory.Get(RepositoryType.Pundit, File.OpenRead(results[0].FullName))) return(reader.ReadManifest()); }
public bool PackageExist(PackageKey package) { return(File.Exists(Path.Combine(RootPath, package.GetFileName()))); }