Example #1
0
        private UDirectory GetPackageDirectory(string packageName, PackageVersionRange versionRange, IPackageConstraintProvider constraintProvider = null, bool allowPreleaseVersion = false, bool allowUnlisted = false)
        {
            if (packageName == null)
            {
                throw new ArgumentNullException("packageName");
            }

            if (store != null)
            {
                var versionSpec = versionRange.ToVersionSpec();
                var package     = store.Manager.LocalRepository.FindPackage(packageName, versionSpec, constraintProvider ?? NullConstraintProvider.Instance, allowPreleaseVersion, allowUnlisted);

                // If package was not found,
                if (package != null)
                {
                    var directory = store.PathResolver.GetPackageDirectory(package);
                    if (directory != null)
                    {
                        return(directory);
                    }
                }
            }

            // TODO: Check version for default package
            if (packageName == DefaultPackageName)
            {
                if (versionRange == null || versionRange.Contains(DefaultPackageVersion))
                {
                    return(defaultPackageDirectory);
                }
            }

            return(null);
        }
Example #2
0
        /// <summary>
        /// Gets the filename to the specific package <paramref name="packageName"/> using the version <paramref name="versionRange"/> if not null, otherwise the <paramref name="constraintProvider"/> if specified.
        /// If no constraints are specified, the first entry if any are founds is used to get the filename.
        /// </summary>
        /// <param name="packageName">Name of the package.</param>
        /// <param name="versionRange">The version range.</param>
        /// <param name="constraintProvider">The package constraint provider.</param>
        /// <param name="allowPreleaseVersion">if set to <c>true</c> [allow prelease version].</param>
        /// <param name="allowUnlisted">if set to <c>true</c> [allow unlisted].</param>
        /// <returns>A location on the disk to the specified package or null if not found.</returns>
        /// <exception cref="System.ArgumentNullException">packageName</exception>
        public UFile GetPackageFileName(string packageName, PackageVersionRange versionRange = null, ConstraintProvider constraintProvider = null, bool allowPreleaseVersion = true, bool allowUnlisted = false)
        {
            if (packageName == null)
            {
                throw new ArgumentNullException(nameof(packageName));
            }

            var package = store.FindLocalPackage(packageName, versionRange, constraintProvider, allowPreleaseVersion, allowUnlisted);

            // If package was not found,
            if (package != null)
            {
                return(UPath.Combine(store.GetInstallPath(package), new UFile(packageName + Package.PackageFileExtension)));
            }

            // TODO: Check version for default package
            if (packageName == DefaultPackageName)
            {
                if (versionRange == null || versionRange.Contains(DefaultPackageVersion))
                {
                    return(UPath.Combine(UPath.Combine(UPath.Combine(InstallationPath, (UDirectory)store.RepositoryPath), defaultPackageDirectory), new UFile(packageName + Package.PackageFileExtension)));
                }
            }

            return(null);
        }
Example #3
0
        private UDirectory GetPackageDirectory(string packageName, PackageVersionRange versionRange, IPackageConstraintProvider constraintProvider = null, bool allowPreleaseVersion = false, bool allowUnlisted = false)
        {
            if (packageName == null) throw new ArgumentNullException("packageName");

            if (store != null)
            {
                var versionSpec = versionRange.ToVersionSpec();
                var package = store.Manager.LocalRepository.FindPackage(packageName, versionSpec, constraintProvider ?? NullConstraintProvider.Instance, allowPreleaseVersion, allowUnlisted);

                // If package was not found, 
                if (package != null)
                {
                    var directory = store.PathResolver.GetPackageDirectory(package);
                    if (directory != null)
                    {
                        return directory;
                    }
                }
            }

            // TODO: Check version for default package
            if (packageName == DefaultPackageName)
            {
                if (versionRange == null || versionRange.Contains(DefaultPackageVersion))
                {
                    return defaultPackageDirectory;
                }
            }

            return null;
        }