Exemple #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 {}
            }
        }
        public async Task Add(string filename)
        {
            var metadata = await ApplicationPackageTools.GetMetadataAsync(filename);

            if (metadata == null)
            {
                throw new Exception("No metadata file found in package!");
            }

            await base.Add(filename, metadata);
        }
        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 { }
            }
        }
Exemple #4
0
        private void PackageClient_OnPushApplicationPackage(string filename, RemoteTaskCompletionSource taskHandle)
        {
            Task.Run(async() => {
                var metadata = await ApplicationPackageTools.GetMetadataAsync(filename);
                if (metadata == null)
                {
                    throw new ApplicationException($"Invalid Project Package '{filename}'! No metadata found.");
                }

                await applicationPackages.Add(filename);
                PushedApplicationPackageList.Add(new PackageReference(metadata.Id, metadata.Version));
            }).ContinueWith(taskHandle.FromTask);
        }