Beispiel #1
0
        public override int Execute(string[] commandLineArguments)
        {
            var packageFile = variables.GetPathToPrimaryPackage(fileSystem, true);

            var journal = new DeploymentJournal(fileSystem, SemaphoreFactory.Get(), variables);

            var conventions = new List <IConvention>
            {
                new AlreadyInstalledConvention(log, journal),
                new TransferPackageConvention(log, fileSystem),
            };

            var deployment       = new RunningDeployment(packageFile, variables);
            var conventionRunner = new ConventionProcessor(deployment, conventions);

            try
            {
                conventionRunner.RunConventions();
                deploymentJournalWriter.AddJournalEntry(deployment, true);
            }
            catch (Exception)
            {
                deploymentJournalWriter.AddJournalEntry(deployment, false);
                throw;
            }

            return(0);
        }
Beispiel #2
0
        public int Execute(string[] args)
        {
            var pathToPrimaryPackage = variables.GetPathToPrimaryPackage(fileSystem, false);

            var isEnableNoMatchWarningSet = variables.IsSet(PackageVariables.EnableNoMatchWarning);

            if (!isEnableNoMatchWarningSet && !string.IsNullOrEmpty(GetAdditionalFileSubstitutions()))
            {
                variables.Add(PackageVariables.EnableNoMatchWarning, "true");
            }

            var runningDeployment = new RunningDeployment(pathToPrimaryPackage, variables);

            if (pathToPrimaryPackage != null)
            {
                extractPackage.ExtractToStagingDirectory(pathToPrimaryPackage);
            }

            var filesToSubstitute = GetFilesToSubstitute();

            substituteInFiles.Substitute(runningDeployment, filesToSubstitute);

            InstallAsync(runningDeployment).GetAwaiter().GetResult();

            return(0);
        }
        public override int Execute(string[] commandLineArguments)
        {
            var packageFile = variables.GetPathToPrimaryPackage(fileSystem, true);

            if (packageFile == null) // required: true in the above call means it will throw rather than return null, but there's no way to tell the compiler that. And ! doesn't work in older frameworks
            {
                throw new CommandException("Package File path could not be determined");
            }

            var journal = new DeploymentJournal(fileSystem, SemaphoreFactory.Get(), variables);

            var conventions = new List <IConvention>
            {
                new AlreadyInstalledConvention(log, journal),
                new TransferPackageConvention(log, fileSystem),
            };

            var deployment       = new RunningDeployment(packageFile, variables);
            var conventionRunner = new ConventionProcessor(deployment, conventions, log);

            try
            {
                conventionRunner.RunConventions();
                deploymentJournalWriter.AddJournalEntry(deployment, true);
            }
            catch (Exception)
            {
                deploymentJournalWriter.AddJournalEntry(deployment, false);
                throw;
            }

            return(0);
        }
Beispiel #4
0
        public async Task Execute(ILifetimeScope lifetimeScope, IVariables variables)
        {
            var pathToPrimaryPackage = variables.GetPathToPrimaryPackage(lifetimeScope.Resolve <ICalamariFileSystem>(), false);
            var deployment           = new RunningDeployment(pathToPrimaryPackage, variables);

            try
            {
                foreach (var behaviour in GetBehaviours(lifetimeScope, deployment))
                {
                    await behaviour;

                    if (deployment.Variables.GetFlag(KnownVariables.Action.SkipRemainingConventions))
                    {
                        break;
                    }
                }
            }
            catch (Exception installException)
            {
                Console.Error.WriteLine("Running rollback behaviours...");

                deployment.Error(installException);

                try
                {
                    // Rollback behaviours include tasks like DeployFailed.ps1
                    await ExecuteBehaviour(deployment, lifetimeScope.Resolve <RollbackScriptBehaviour>());
                }
                catch (Exception rollbackException)
                {
                    Console.Error.WriteLine(rollbackException);
                }

                throw;
            }
        }
Beispiel #5
0
        public ExtractPackageCommand(IVariables variables, IExtractPackage extractPackage, ICalamariFileSystem fileSystem)
        {
            this.extractPackage = extractPackage;

            pathToPrimaryPackage = variables.GetPathToPrimaryPackage(fileSystem, true);
        }