コード例 #1
0
        public async Task RunAsync(CancellationToken token)
        {
            // Get the versioned application path
            var appRev = await Context.Applications.GetApplicationRevision(
                appName : Configuration.Apps.Web.AppName)
                         ?? await Context.Applications.RegisterApplicationRevision(
                appName : Configuration.Apps.Web.AppName,
                packageId : Configuration.Apps.Web.PackageId,
                packageVersion : Context.ProjectPackageVersion);

            string packageFilename = null;

            try {
                // Download Package to temp file
                packageFilename = await Context.Packages.PullApplicationPackageAsync(
                    id : Configuration.Apps.Web.PackageId,
                    version : Context.ProjectPackageVersion);

                // Unpackage contents to application path
                await ApplicationPackageTools.UnpackAsync(packageFilename, appRev.ApplicationPath);
            }
            finally {
                try {
                    if (packageFilename != null)
                    {
                        PathEx.Delete(packageFilename);
                    }
                }
                catch {}
            }
        }
コード例 #2
0
        public async Task RunAsync(CancellationToken token)
        {
            using (var block = Context.Output.WriteBlock()) {
                block.Write("Unpackaging ", ConsoleColor.DarkCyan);
                block.Write(Configuration.Apps.Service.AppName, ConsoleColor.Cyan);
                block.WriteLine("...", ConsoleColor.DarkCyan);
            }

            // Get the versioned application path
            var appRev = await Context.Applications.GetApplicationRevision(
                appName : Configuration.Apps.Service.AppName)
                         ?? await Context.Applications.RegisterApplicationRevision(
                appName : Configuration.Apps.Service.AppName,
                packageId : Configuration.Apps.Service.PackageId,
                packageVersion : Context.ProjectPackageVersion);

            string packageFilename = null;

            try {
                // Download Package to temp file
                packageFilename = await Context.Packages.PullApplicationPackageAsync(
                    id : Configuration.Apps.Service.PackageId,
                    version : Context.ProjectPackageVersion);

                // Unpackage contents to application path
                await ApplicationPackageTools.UnpackAsync(packageFilename, appRev.ApplicationPath);

                using (var block = Context.Output.WriteBlock()) {
                    block.Write("Unpackaged ", ConsoleColor.DarkGreen);
                    block.Write(Configuration.Apps.Service.AppName, ConsoleColor.Green);
                    block.WriteLine("successfully.", ConsoleColor.DarkGreen);
                }
            }
            catch (Exception error) {
                using (var block = Context.Output.WriteBlock()) {
                    block.Write("Failed to unpackage ", ConsoleColor.DarkCyan);
                    block.Write(Configuration.Apps.Service.AppName, ConsoleColor.Cyan);
                    block.WriteLine("! ", ConsoleColor.DarkCyan);
                    block.WriteLine(error.UnfoldMessages(), ConsoleColor.DarkYellow);
                }

                throw;
            }
            finally {
                try {
                    if (packageFilename != null)
                    {
                        PathEx.Delete(packageFilename);
                    }
                }
                catch { }
            }
        }