Beispiel #1
0
        public void TestThatTransformConfigOperationCorrectlyTransformsConfigFile()
        {
            var source = WriteTextToTempFile(Consts.Source01);
            var transform = WriteTextToTempFile(Consts.Transform01);
            var destination = source;
            var expectedResultFile = WriteTextToTempFile(Consts.Result01);

            var trans = new TransformConfigOperation(Path.GetDirectoryName(source), Path.GetFileName(source), Path.GetFileName(transform));
            var webDepStatus = new WebDeploymentStatus();
            trans.Execute(webDepStatus, new ConDepConfig(), new ConDepOptions(false, "", false, false, false, false, null));

            Assert.That(webDepStatus.HasErrors, Is.False);

            var actualResult = File.ReadAllText(destination);
            var expectedResult = File.ReadAllText(expectedResultFile);
            Assert.AreEqual(expectedResult.Trim(), actualResult.Trim());
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var exitCode = 0;
            try
            {
                new LogConfigLoader().Load();
                Logger.LogSectionStart("ConDep");

                var optionHandler = new CommandLineOptionHandler(args);
                var configAssemblyLoader = new ConDepAssemblyHandler(optionHandler.Params.AssemblyName);
                var assembly = configAssemblyLoader.GetConfigAssembly();

                var conDepOptions = new ConDepOptions(optionHandler.Params.Context, optionHandler.Params.DeployOnly, optionHandler.Params.InfraOnly, optionHandler.Params.WebDeployExist);
                var envSettings = GetEnvConfig(optionHandler.Params, assembly);

                var status = new WebDeploymentStatus();
                ConDepConfigurationExecutor.ExecuteFromAssembly(assembly, envSettings, conDepOptions, status);

                if(status.HasErrors)
                {
                    exitCode = 1;
                }
                else
                {
                    status.EndTime = DateTime.Now;
                    status.PrintSummery();
                }
            }
            catch (Exception ex)
            {
                exitCode = 1;
                Logger.Error("ConDep reported a fatal error:");
                Logger.Error("Message: " + ex.Message);
                Logger.Error("Stack trace:\n" + ex.StackTrace);
            }
            finally
            {
                Logger.LogSectionEnd("ConDep");
                Environment.Exit(exitCode);
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var exitCode = 0;
            WebQueue webQ = null;
            try
            {
                new LogConfigLoader().Load();
                Logger.TraceLevel = TraceLevel.Info;

                var optionHandler = new CommandLineOptionHandler(args);
                if (optionHandler.Params.InstallWebQ)
                {
                    throw new NotImplementedException();
                }
                else
                {
                    PrintCopyrightMessage();
                    Logger.LogSectionStart("ConDep");
                    if (!string.IsNullOrWhiteSpace(optionHandler.Params.WebQAddress))
                    {
                        webQ = new WebQueue(optionHandler.Params.WebQAddress, optionHandler.Params.Environment);
                        webQ.WebQueuePositionUpdate += (sender, eventArgs) => Logger.Info(eventArgs.Message);
                        webQ.WebQueueTimeoutUpdate += (sender, eventArgs) => Logger.Info(eventArgs.Message);
                        Logger.LogSectionStart("Waiting in Deployment Queue");
                        try
                        {
                            webQ.WaitInQueue(TimeSpan.FromMinutes(30));
                        }
                        finally
                        {
                            Logger.LogSectionEnd("Waiting in Deployment Queue");
                        }
                    }

                    var configAssemblyLoader = new ConDepAssemblyHandler(optionHandler.Params.AssemblyName);
                    var assembly = configAssemblyLoader.GetAssembly();

                    var conDepOptions = new ConDepOptions(optionHandler.Params.DeployAllApps,
                                                          optionHandler.Params.Application,
                                                          optionHandler.Params.DeployOnly,
                                                          optionHandler.Params.WebDeployExist,
                                                          optionHandler.Params.StopAfterMarkedServer,
                                                          optionHandler.Params.ContinueAfterMarkedServer,
                                                          assembly);
                    var envSettings = ConfigHandler.GetEnvConfig(optionHandler.Params.Environment, optionHandler.Params.BypassLB, assembly);

                    var status = new WebDeploymentStatus();
                    ConDepConfigurationExecutor.ExecuteFromAssembly(assembly, envSettings, conDepOptions, status);

                    if (status.HasErrors)
                    {
                        exitCode = 1;
                    }
                    else
                    {
                        status.EndTime = DateTime.Now;
                        status.PrintSummary();
                    }
                }
            }
            catch (Exception ex)
            {
                exitCode = 1;
                Logger.Error("ConDep reported a fatal error:");
                Logger.Error("Message: " + ex.Message);
                Logger.Verbose("Stack trace:\n" + ex.StackTrace);
            }
            finally
            {
                if(webQ != null)
                {
                    webQ.LeaveQueue();
                }

                Logger.LogSectionEnd("ConDep");
                Environment.Exit(exitCode);
            }
        }