Ejemplo n.º 1
0
 public static async Task <ZipArchiveEntry> SetSimpleNuspecAsync(ZipArchive zip,
                                                                 string packageId,
                                                                 string packageVersion,
                                                                 string language,
                                                                 bool frameworkAssemblies,
                                                                 bool dependencies)
 {
     return(await zip.AddEntryAsync(
                $"{packageId}.nuspec",
                GetSimpleNuspecString(packageId, packageVersion, language, frameworkAssemblies, dependencies)));
 }
Ejemplo n.º 2
0
        public static async Task <FileInfo> GeneratePackageAsync(
            string path,
            string packageId,
            string packageVersion,
            string language,
            DateTime entryModifiedTime,
            IEnumerable <string> zipEntries,
            IEnumerable <string> zipContents,
            bool frameworkAssemblies = false,
            bool dependencies        = false)
        {
            if (zipEntries == null)
            {
                throw new ArgumentNullException(nameof(zipEntries));
            }
            if (zipContents == null)
            {
                throw new ArgumentNullException(nameof(zipContents));
            }
            if (zipEntries.Count() != zipContents.Count())
            {
                throw new ArgumentException("TEST Exception: zipEntries.Length should be equal to zipContents.Length");
            }

            var fileInfo = GetFileInfo(path, packageId, packageVersion);

            using (var zip = new ZipArchive(File.Create(fileInfo.FullName), ZipArchiveMode.Update))
            {
                var tasks
                    = zipEntries.Zip(zipContents, async(entry, content) => await zip.AddEntryAsync(entry, content));
                var entries = await Task.WhenAll(tasks);

                entries.ToList().ForEach(entry => entry.LastWriteTime = entryModifiedTime);
                await SetSimpleNuspecAsync(
                    zip,
                    packageId,
                    packageVersion,
                    language,
                    frameworkAssemblies,
                    dependencies);
            }

            return(fileInfo);
        }