public static bool PackageExists(LocalDirectoryNugetRepository repository, PackageID packageID, Version packageVersion) { // Does the version directory of the package directory exist? var packageVersionDirectoryPath = LocalDirectoryNugetRepository.GetPackageVersionDirectoryPath(repository, packageID, packageVersion); if (!packageVersionDirectoryPath.Exists()) { return(false); } var nuspecFilePath = NuGetIoUtilities.GetNuspecFilePath(packageVersionDirectoryPath); // Does the nuspec file in the correct directory actually state the specified packageID and version number? var packageSpecification = NuGetIoUtilities.GetPackageSpecification(nuspecFilePath); if (packageSpecification.ID != packageID) { return(false); } if (packageSpecification.Version != packageVersion) { return(false); } return(true); }
public static void ListPackageVersionInformationNuspec(NuspecFilePath nuspecFilePath, TextWriter writer) { var packageSpecification = NuGetIoUtilities.GetPackageSpecification(nuspecFilePath); var versionForDisplay = packageSpecification.Version.ToStringDisplay(); writer.WriteLine($"{packageSpecification.ID} {versionForDisplay}"); }