예제 #1
0
        public void PackageFolderReader_Basic()
        {
            var packageNupkg = TestPackages.GetLegacyTestPackage();
            var zip = new ZipArchive(packageNupkg.OpenRead());
            PackageReader zipReader = new PackageReader(zip);

            var folder = Path.Combine(packageNupkg.Directory.FullName, Guid.NewGuid().ToString());

            var zipFile = new ZipArchive(File.OpenRead(packageNupkg.FullName));

            zipFile.ExtractAll(folder);

            var folderReader = new PackageFolderReader(folder);

            Assert.Equal(zipReader.GetIdentity(), folderReader.GetIdentity(), new PackageIdentityComparer());

            Assert.Equal(zipReader.GetLibItems().Count(), folderReader.GetLibItems().Count());

            Assert.Equal(zipReader.GetReferenceItems().Count(), folderReader.GetReferenceItems().Count());

            Assert.Equal(zipReader.GetReferenceItems().First().Items.First(), folderReader.GetReferenceItems().First().Items.First());
        }
예제 #2
0
        public void ExtractTo(string dir)
        {
            if (string.IsNullOrWhiteSpace(this.file) || !File.Exists(this.file))
                throw new InvalidOperationException("Can't extract Project Template, because the template file is missing");

            using (FileStream stream = File.OpenRead(this.file))
            using (ZipArchive templateZip = new ZipArchive(stream))
            {
                templateZip.ExtractAll(dir, true);
            }
            if (File.Exists(Path.Combine(dir, "TemplateIcon.png"))) File.Delete(Path.Combine(dir, "TemplateIcon.png"));
            if (File.Exists(Path.Combine(dir, "TemplateInfo.xml"))) File.Delete(Path.Combine(dir, "TemplateInfo.xml"));
        }