コード例 #1
0
        public void Import(NuspecCoreReader reader, MazeFramework framework)
        {
            foreach (var metadataKeyValue in reader.GetMetadata())
            {
                switch (metadataKeyValue.Key)
                {
                case "id":
                    continue;

                case "version":
                    var version = NuGetVersion.Parse(metadataKeyValue.Value);
                    if (_version != null && _version != version)
                    {
                        Console.Error.WriteLine("The packages have different versions.");
                    }
                    else
                    {
                        _version = version;
                    }

                    break;

                case "description":
                    if (metadataKeyValue.Value == "Package Description")
                    {
                        continue;
                    }

                    ApplyValue(metadataKeyValue);
                    break;

                default:
                    ApplyValue(metadataKeyValue);
                    break;
                }
            }

            var dependencies = reader.GetDependencies().ToList();

            Dependencies.Add(framework, dependencies);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: 5l1v3r1/Maze-1
        private static void CopyNupkgToOutput(DirectoryInfo directory, string moduleName, string packagePath, PseudoNuspecBuilder builder)
        {
            using (var sourceFile = ZipFile.OpenRead(packagePath))
            {
                var nuspecFile = sourceFile.Entries.Single(x => x.Name.EndsWith(".nuspec"));
                TryParseFrameworkFromName(nuspecFile.Name, moduleName, out var framework);

                using (var stream = nuspecFile.Open())
                {
                    var reader = new NuspecCoreReader(stream);

                    var id = reader.GetId();
                    if (framework == null)
                    {
                        if (Enum.TryParse <MazeFramework>(id.Split('.').Last(), out var fw))
                        {
                            framework = fw;
                        }
                        else
                        {
                            Console.WriteLine($"Package {id} could not be associated to an Maze framework. It will be included as a reference.");

                            var tempFolder = Path.Combine(directory.FullName, reader.GetId());
                            ExtractPackage(tempFolder, sourceFile);

                            builder.IncludedReferences.Add(new IncludedReference
                            {
                                Dependencies = reader.GetDependencies().ToList(), ContentPath = tempFolder, Id = reader.GetId()
                            });
                            return;
                        }
                    }

                    builder.Import(reader, framework.Value);
                }

                var nuGetFramework = framework.Value.ToNuGetFramework();
                ExtractPackage(Path.Combine(directory.FullName, "lib", nuGetFramework.GetShortFolderName()), sourceFile);
            }
        }