Ejemplo n.º 1
0
        public void NuspecReaderTests_Language()
        {
            NuspecReader reader = GetReader(BasicNuspec);

            var language = reader.GetLanguage();

            Assert.Equal("en-US", language);
        }
Ejemplo n.º 2
0
        public ServerPackage(NuspecReader package, PackageDerivedData packageDerivedData)
        {
            Id         = package.GetId();
            Version    = package.GetVersion();
            Title      = package.GetTitle();
            Authors    = package.GetAuthors();
            Owners     = package.GetOwners();
            IconUrl    = package.GetIconUrl();
            LicenseUrl = package.GetLicenseUrl();
            ProjectUrl = package.GetProjectUrl();
            RequireLicenseAcceptance = package.GetRequireLicenseAcceptance();
            DevelopmentDependency    = package.GetDevelopmentDependency();
            Description             = package.GetDescription();
            Summary                 = package.GetSummary();
            ReleaseNotes            = package.GetReleaseNotes();
            Language                = package.GetLanguage();
            Tags                    = package.GetTags();
            Copyright               = package.GetCopyright();
            MinClientVersion        = package.GetMinClientVersion();
            ReportAbuseUrl          = null;
            DownloadCount           = 0;
            SemVer1IsAbsoluteLatest = false;
            SemVer1IsLatest         = false;
            SemVer2IsAbsoluteLatest = false;
            SemVer2IsLatest         = false;
            //FIXME is this OK?
            Listed = true;

            IsSemVer2 = IsPackageSemVer2(package);

            _dependencySets = package.GetDependencyGroups().ToList();
            Dependencies    = _dependencySets.DependencySetsAsString();

            _supportedFrameworks = package.GetFrameworkReferenceGroups().Select(f => f.TargetFramework).ToList();
            SupportedFrameworks  = string.Join("|", _supportedFrameworks.Select(f => f.GetFrameworkString()));

            PackageSize          = packageDerivedData.PackageSize;
            PackageHash          = packageDerivedData.PackageHash;
            PackageHashAlgorithm = packageDerivedData.PackageHashAlgorithm;
            LastUpdated          = packageDerivedData.LastUpdated;
            Created  = packageDerivedData.Created;
            Path     = packageDerivedData.Path;
            FullPath = packageDerivedData.FullPath;
        }
Ejemplo n.º 3
0
        private async Task <List <string> > GetSatelliteFilesForLibraryAsync(FrameworkSpecificGroup libraryFrameworkSpecificGroup, PackageReaderBase packageReader,
                                                                             CancellationToken cancellationToken)
        {
            var satelliteFiles = new List <string>();

            using (var nuspec = await packageReader.GetNuspecAsync(cancellationToken))
            {
                var nuspecReader = new NuspecReader(nuspec);

                var satelliteFilesInGroup = libraryFrameworkSpecificGroup.Items
                                            .Where(item => Path.GetDirectoryName(item)
                                                   .Split(Path.DirectorySeparatorChar)
                                                   .Contains(nuspecReader.GetLanguage(), StringComparer.OrdinalIgnoreCase)).ToList();

                satelliteFiles.AddRange(satelliteFilesInGroup);

                return(satelliteFiles);
            }
        }
        /// <summary>
        /// A package is deemed to be a satellite package if it has a language property set, the id of the package is
        /// of the format [.*].[Language]
        /// and it has at least one dependency with an id that maps to the runtime package .
        /// </summary>
        public static bool IsSatellitePackage(this IPackageCoreReader packageReader)
        {
            // A satellite package has the following properties:
            //     1) A package suffix that matches the package's language, with a dot preceding it
            //     2) A dependency on the package with the same Id minus the language suffix
            //     3) The dependency can be found by Id in the repository (as its path is needed for installation)
            // Example: foo.ja-jp, with a dependency on foo

            var nuspecReader    = new NuspecReader(packageReader.GetNuspec());
            var packageId       = nuspecReader.GetId();
            var packageLanguage = nuspecReader.GetLanguage();

            if (!string.IsNullOrEmpty(packageLanguage)
                &&
                packageId.EndsWith('.' + packageLanguage, StringComparison.OrdinalIgnoreCase))
            {
                // The satellite pack's Id is of the format <Core-Package-Id>.<Language>. Extract the core package id using this.
                // Additionally satellite packages have a strict dependency on the core package
                var localruntimePackageId = packageId.Substring(0, packageId.Length - packageLanguage.Length - 1);

                foreach (var group in nuspecReader.GetDependencyGroups())
                {
                    foreach (var dependencyPackage in group.Packages)
                    {
                        if (dependencyPackage.Id.Equals(localruntimePackageId, StringComparison.OrdinalIgnoreCase) &&
                            dependencyPackage.VersionRange != null &&
                            dependencyPackage.VersionRange.MaxVersion == dependencyPackage.VersionRange.MinVersion &&
                            dependencyPackage.VersionRange.IsMaxInclusive &&
                            dependencyPackage.VersionRange.IsMinInclusive)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }