예제 #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 <ApplicationPackage> UnpackAsync(string filename, string path)
        {
            PathEx.CreatePath(path);

            ApplicationPackage metadata = null;

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

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

            return(metadata);
        }
예제 #3
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);
        }
예제 #4
0
        public async Task <ApplicationPackage> UnpackAsync(string filename, string path)
        {
            PathEx.CreatePath(path);

            ApplicationPackage metadata = null;

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

                context.Output.WriteBlock()
                .Write("Unpacking ", ConsoleColor.DarkCyan)
                .Write(metadata.Id, ConsoleColor.Cyan)
                .Write(" @", ConsoleColor.DarkCyan)
                .Write(metadata.Version, ConsoleColor.Cyan)
                .WriteLine("...", ConsoleColor.DarkCyan)
                .Post();

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

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

                    throw;
                }
            });

            return(metadata);
        }