Exemple #1
0
        public ServerPackage CreateServerPackage(LocalPackageInfo package, bool enableDelisting)
        {
            // File names
            var packageFileName = package.Path;
            var hashFileName    = Path.ChangeExtension(packageFileName, PackagingCoreConstants.HashFileExtension);

            // File system
            var physicalFileSystem = _fileSystem as PhysicalFileSystem;

            // Build package info
            var packageDerivedData = new PackageDerivedData();

            // Read package hash
            using (var reader = new StreamReader(_fileSystem.OpenFile(hashFileName)))
            {
                packageDerivedData.PackageHash = reader.ReadToEnd().Trim();
            }

            // Read package info
            var localPackage = package;

            if (physicalFileSystem != null)
            {
                // Read package info from file system
                var fileInfo = new FileInfo(packageFileName);
                packageDerivedData.PackageSize = fileInfo.Length;

                packageDerivedData.LastUpdated = _fileSystem.GetLastModified(packageFileName);
                packageDerivedData.Created     = _fileSystem.GetCreated(packageFileName);
                packageDerivedData.Path        = packageFileName;
                packageDerivedData.FullPath    = fileInfo.FullName;

                // if (enableDelisting && localPackage != null)
                // {
                //     // hidden packages are considered delisted
                //     localPackage.Listed = !fileInfo.Attributes.HasFlag(FileAttributes.Hidden);
                // }
            }
            else
            {
                throw new NotSupportedException("Read package info from package (slower)");
                // FIXME Read package info from package (slower)
                // using (var stream = package.GetStream())
                // {
                //     packageDerivedData.PackageSize = stream.Length;
                // }

                // packageDerivedData.LastUpdated = DateTime.MinValue;
                // packageDerivedData.Created = DateTime.MinValue;
            }

            // TODO: frameworks?

            // Build entry
            var serverPackage = new ServerPackage(package.Nuspec, packageDerivedData);

            return(serverPackage);
        }
Exemple #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;
        }
Exemple #3
0
        public ServerPackage(IPackage package, PackageDerivedData packageDerivedData)
        {
            Id         = package.Id;
            Version    = new NuGetVersion(package.Version.ToFullString());
            Title      = package.Title;
            Authors    = string.Join(",", package.Authors);
            Owners     = string.Join(",", package.Owners);
            IconUrl    = package.IconUrl;
            LicenseUrl = package.LicenseUrl;
            ProjectUrl = package.ProjectUrl;
            RequireLicenseAcceptance = package.RequireLicenseAcceptance;
            DevelopmentDependency    = package.DevelopmentDependency;
            Description             = package.Description;
            Summary                 = package.Summary;
            ReleaseNotes            = package.ReleaseNotes;
            Language                = package.Language;
            Tags                    = package.Tags;
            Copyright               = package.Copyright;
            MinClientVersion        = package.MinClientVersion;
            ReportAbuseUrl          = package.ReportAbuseUrl;
            DownloadCount           = package.DownloadCount;
            SemVer1IsAbsoluteLatest = false;
            SemVer1IsLatest         = false;
            SemVer2IsAbsoluteLatest = false;
            SemVer2IsLatest         = false;
            Listed                  = package.Listed;
            Published               = package.Published;

            IsSemVer2 = IsPackageSemVer2(package);

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

            _supportedFrameworks = package.GetSupportedFrameworks().ToList();
            SupportedFrameworks  = string.Join("|", package.GetSupportedFrameworks().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;
        }