Пример #1
0
        public async Task <ProjectPackage> UnpackAsync(string filename, string path)
        {
            PathEx.CreatePath(path);

            ProjectPackage metadata = null;

            await PackageTools.ReadArchive(filename, async archive => {
                metadata = await PackageTools.ParseMetadataAsync <ProjectPackage>(archive);

                var packageName = $"{metadata.Id} @ {metadata.Version}";

                context.Output.WriteLine($"Unpacking '{packageName}'...", ConsoleColor.Gray);

                try {
                    await PackageTools.UnpackBin(archive, path);

                    context.Output.WriteLine($"Unpacked '{packageName}' successfully.", ConsoleColor.Gray);
                }
                catch (Exception error) {
                    using (var block = context.Output.WriteBlock()) {
                        block.Write($"Failed to unpack '{packageName}'! ", ConsoleColor.DarkRed);
                        block.WriteLine(error.UnfoldMessages(), ConsoleColor.DarkYellow);
                    }

                    throw;
                }
            });

            return(metadata);
        }
Пример #2
0
        public static async Task <ProjectPackage> GetMetadataAsync(string filename)
        {
            ProjectPackage package = null;

            await PackageTools.ReadArchive(filename, async archive => {
                package = await PackageTools.ParseMetadataAsync <ProjectPackage>(archive);
            });

            return(package);
        }
Пример #3
0
        private static void AppendMetadata(ZipArchive archive, PackageDefinition definition, string version)
        {
            var metadata = new ProjectPackage {
                Id               = definition.Id,
                Name             = definition.Name,
                Description      = definition.Description,
                AssemblyFilename = definition.Assembly,
                ScriptName       = definition.Script,
                Version          = version,
            };

            PackageTools.AppendMetadata(archive, metadata, version);
        }
Пример #4
0
        public static async Task <ProjectPackage> UnpackAsync(string filename, string path)
        {
            PathEx.CreatePath(path);

            ProjectPackage metadata = null;

            await PackageTools.ReadArchive(filename, async archive => {
                metadata = await PackageTools.ParseMetadataAsync <ProjectPackage>(archive);

                await PackageTools.UnpackBin(archive, path);
            });

            return(metadata);
        }
Пример #5
0
        public static async Task <ProjectPackage> UnpackAsync(string filename, string path)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            ProjectPackage metadata = null;

            await PackageTools.ReadArchive(filename, async archive => {
                metadata = await PackageTools.ParseMetadataAsync <ProjectPackage>(archive);

                await PackageTools.UnpackBin(archive, path);
            });

            return(metadata);
        }
Пример #6
0
        public async Task <ProjectPackage> UnpackAsync(string filename, string path)
        {
            PathEx.CreatePath(path);

            ProjectPackage metadata = null;

            await PackageTools.ReadArchive(filename, async archive => {
                metadata = await PackageTools.ParseMetadataAsync <ProjectPackage>(archive);

                using (var block = context.Output.WriteBlock()) {
                    block.Write("Unpacking ", ConsoleColor.DarkCyan);
                    block.Write(metadata.Id, ConsoleColor.Cyan);
                    block.Write(" @", ConsoleColor.DarkCyan);
                    block.Write(metadata.Version, ConsoleColor.Cyan);
                    block.WriteLine("...", ConsoleColor.DarkCyan);
                }

                try {
                    await PackageTools.UnpackBin(archive, path);

                    using (var block = context.Output.WriteBlock()) {
                        block.Write("Unpacked ", ConsoleColor.DarkBlue);
                        block.Write(metadata.Id, ConsoleColor.Blue);
                        block.Write(" @", ConsoleColor.DarkBlue);
                        block.Write(metadata.Version, ConsoleColor.Blue);
                        block.WriteLine(" successfully.", ConsoleColor.DarkBlue);
                    }
                }
                catch (Exception error) {
                    using (var block = context.Output.WriteBlock()) {
                        block.Write("Failed to unpack ", ConsoleColor.DarkRed);
                        block.Write(metadata.Id, ConsoleColor.Red);
                        block.Write(" @", ConsoleColor.DarkRed);
                        block.Write(metadata.Version, ConsoleColor.Red);
                        block.WriteLine("!", ConsoleColor.DarkRed);
                        block.WriteLine(error.UnfoldMessages(), ConsoleColor.DarkYellow);
                    }

                    throw;
                }
            });

            return(metadata);
        }