Ejemplo n.º 1
0
        static IEnumerable <string> GetPackageLookupPaths(string packageId, NuGetVersion version, Uri feedUri)
        {
            // Files created by the path resolver. This would take into account the non-side-by-side scenario
            // and we do not need to match this for id and version.
            var packageFileName       = GetPackageFileName(packageId, version);
            var filesMatchingFullName = GetPackageFiles(feedUri, packageFileName);

            if (version != null && version.Version.Revision < 1)
            {
                // If the build or revision number is not set, we need to look for combinations of the format
                // * Foo.1.2.nupkg
                // * Foo.1.2.3.nupkg
                // * Foo.1.2.0.nupkg
                // * Foo.1.2.0.0.nupkg
                // To achieve this, we would look for files named 1.2*.nupkg if both build and revision are 0 and
                // 1.2.3*.nupkg if only the revision is set to 0.
                string partialName = version.Version.Build < 1 ?
                                     String.Join(".", packageId, version.Version.Major, version.Version.Minor) :
                                     String.Join(".", packageId, version.Version.Major, version.Version.Minor, version.Version.Build);
                partialName += "*" + CrossPlatform.GetPackageExtension();

                // Partial names would result is gathering package with matching major and minor but different build and revision.
                // Attempt to match the version in the path to the version we're interested in.
                var partialNameMatches = GetPackageFiles(feedUri, partialName).Where(path => FileNameMatchesPattern(packageId, version, path));
                return(Enumerable.Concat(filesMatchingFullName, partialNameMatches));
            }
            return(filesMatchingFullName);
        }
Ejemplo n.º 2
0
        static IEnumerable <string> GetPackageFiles(Uri feedUri, string filter = null)
        {
            var feedPath = feedUri.LocalPath;

            filter = filter ?? "*" + CrossPlatform.GetPackageExtension();

            // Check for package files one level deep. We use this at package install time
            // to determine the set of installed packages. Installed packages are copied to
            // {id}.{version}\{packagefile}.{extension}.
            foreach (var dir in Directory.EnumerateDirectories(feedPath))
            {
                foreach (var path in GetFiles(dir, filter))
                {
                    yield return(path);
                }
            }

            // Check top level directory
            foreach (var path in GetFiles(feedPath, filter))
            {
                yield return(path);
            }
        }
Ejemplo n.º 3
0
        string GetFilePathToDownloadPackageTo(string cacheDirectory, string packageId, string version)
        {
            var name = packageId + "." + version + "_" + BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", string.Empty) + CrossPlatform.GetPackageExtension();

            return(Path.Combine(cacheDirectory, name));
        }
Ejemplo n.º 4
0
 static string GetPackageFileName(string packageId, NuGetVersion version)
 {
     return(packageId + "." + version + CrossPlatform.GetPackageExtension());
 }