예제 #1
0
        private void ProcessNugetPackage(string nugetFileSpec)
        {
            FileName = nugetFileSpec;

            Directory = Path.GetDirectoryName(nugetFileSpec);
            using (var archive = ZipFile.OpenRead(nugetFileSpec))
            {
                foreach (var entry in archive.Entries)
                {
                    if (entry.Name.EndsWith(".nuspec", StringComparison.InvariantCultureIgnoreCase))
                    {
                        var stream = entry.Open();
                        DateTime = entry.LastWriteTime.DateTime;
                        using (var reader = new StreamReader(stream))
                        {
                            RawNuSpec = reader.ReadToEnd();
                        }
                        ProcessNuSpecXml();
                    }
                    else if (entry.Name.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase))
                    {
                        var unencodedName     = WebUtility.UrlDecode(entry.Name);
                        var unencodedFullName = WebUtility.UrlDecode(entry.FullName);
                        var folderName        = Path.GetDirectoryName(unencodedFullName) ?? ".";
                        var framework         = AssemblyInfo.Framework(folderName);

                        if (_frameworkFilter == null || framework != null && _frameworkFilter(AssemblyInfo.Framework(folderName)))
                        {
                            if (!_assemblies.TryGetValue(unencodedName, out var assemblyInfo))
                            {
                                assemblyInfo = new AssemblyInfo {
                                    FileName = unencodedName
                                };
                                _assemblies[unencodedName] = assemblyInfo;
                            }

                            assemblyInfo.Folders.Add(folderName);

                            if (!Folders.TryGetValue(folderName, out var folder))
                            {
                                folder = new List <string>();
                                Folders[folderName] = folder;
                            }

                            folder.Add(unencodedName);
                        }
                    }
                }
            }
        }