示例#1
0
        public IReadOnlyList <SourceFile> GetSourceFiles(ILog log)
        {
            var isNetFx  = Name == "Calamari";
            var isCloud  = Name == "Calamari.Cloud";
            var platform = isNetFx || isCloud
                ? "netfx"
                : Name.Split('.')[1];

            var archivePath = Path.Combine(packageReference.ResolvedPath, $"{Name}.{Version}.nupkg".ToLower());

            if (!File.Exists(archivePath))
            {
                throw new Exception($"Could not find the source NuGet package {archivePath} does not exist");
            }

            using (var zip = ZipFile.OpenRead(archivePath))
                return(zip.Entries
                       .Where(e => !string.IsNullOrEmpty(e.Name))
                       .Where(e => e.FullName != "[Content_Types].xml")
                       .Where(e => !e.FullName.StartsWith("_rels"))
                       .Where(e => !e.FullName.StartsWith("package/services"))
                       .Select(entry => new SourceFile
                {
                    PackageId = isCloud ? "Calamari.Cloud" : "Calamari",
                    Version = Version,
                    Platform = platform,
                    ArchivePath = archivePath,
                    IsNupkg = true,
                    FullNameInDestinationArchive = entry.FullName,
                    FullNameInSourceArchive = entry.FullName,
                    Hash = hasher.Hash(entry)
                })
                       .ToArray());
        }
 private IEnumerable <SourceFile> ReadSashimiPackagedZip(string toolZipPath)
 {
     using (var zip = ZipFile.OpenRead(toolZipPath))
         return(zip.Entries
                .Where(e => !string.IsNullOrEmpty(e.Name))
                .Select(entry =>
         {
             // Sashimi zips have each full Calamari executable in folders according to platform
             var parts = entry.FullName.Split('/');
             return new SourceFile
             {
                 PackageId = Path.GetFileNameWithoutExtension(toolZipPath),
                 Version = Version,
                 Platform = parts[0],
                 ArchivePath = toolZipPath,
                 IsNupkg = false,
                 FullNameInDestinationArchive = string.Join("/", parts.Skip(1)),
                 FullNameInSourceArchive = entry.FullName,
                 Hash = hasher.Hash(entry)
             };
         })
                .ToArray());
 }