public async Task MetadataResource_Local() { NuGet.LocalPackageRepository legacyRepo = new NuGet.LocalPackageRepository(@"C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Packages"); var sourceRepo = GetSourceRepository(legacyRepo); var resource = await sourceRepo.GetResource <MetadataResource>(); // Microsoft.jQuery.Unobtrusive.Validation.2.0.30506.0 Assert.True(await resource.Exists(new PackageIdentity("Microsoft.jQuery.Unobtrusive.Validation", NuGetVersion.Parse("2.0.30506.0")), CancellationToken.None)); Assert.True(await resource.Exists(new PackageIdentity("Microsoft.jQuery.Unobtrusive.Validation", NuGetVersion.Parse("2.0.30506")), CancellationToken.None)); Assert.True(await resource.Exists(new PackageIdentity("Microsoft.jQUERY.Unobtrusive.validation", NuGetVersion.Parse("2.0.30506")), CancellationToken.None)); Assert.False(await resource.Exists(new PackageIdentity("Microsoft.jQUERY.Unobtrusive.validation", NuGetVersion.Parse("2.0.30506.1")), CancellationToken.None)); }
private static NuGet.IPackage FindPackage(ILogger logger, IReference newPackage, string sourceDirectory) { var repo = new NuGet.LocalPackageRepository(sourceDirectory); var packages = (from p in repo.GetPackages() where p.Id == newPackage.Name orderby p.Version descending select p); var package = packages.FirstOrDefault(); if (package == null) { logger.Error("Could not find package '{0}' in '{1}'!", newPackage.Name, sourceDirectory); } return package; }