Ejemplo n.º 1
0
 //// See deployment example for real use case. You can also apply attribute Target on method. https://github.com/flubu-core/flubu.core/wiki/2-Build-script-fundamentals#Targets
 private void ReuseSetOfTargetsExample(ITarget target, string directoryName, string directoryName2)
 {
     //// Retry, When, OnError, Finally, ForMember, NoLog, DoNotFailOnError can be applied on all tasks.
     target.AddTask(x =>
                    x.CreateDirectoryTask(directoryName, true).OnError((c, e) => c.LogInfo("Dummy example of onError.")))
     .When(c => true)
     .AddTask(x => x.CreateDirectoryTask(directoryName2, true).Finally(c => c.LogInfo("Dummy example of finally.")))
     ////You can group task and apply When, OnError, Finally on group of tasks. .
     .Group(
         t =>
     {
         t.AddTask(x => x.DeleteDirectoryTask(directoryName, false).DoNotFailOnError().NoLog());
         t.AddTask(x => x.DeleteDirectoryTask(directoryName2, true).Retry(3, 1000));
     },
         onFinally: c =>
     {
         c.LogInfo("Dummy example of OnFinally and When on group of tasks.");
     },
         onError: (c, ex) =>
     {
         c.LogInfo("Dummy example of OnError on group of tasks.");
     },
         when: c => true
         );
 }
Ejemplo n.º 2
0
 private void Deploy(ITarget target, string deployPath)
 {
     target
     .AddTask(x => x.IisTasks().CreateAppPoolTask("Example app pool").Mode(CreateApplicationPoolMode.DoNothingIfExists))
     .AddTask(x => x.IisTasks().ControlAppPoolTask("Example app pool", ControlApplicationPoolAction.Stop).DoNotFailOnError())
     .Do(UnzipPackage)
     .AddTask(x => x.CopyDirectoryStructureTask(@"Packages\ExampleApp", deployPath, true).Retry(20, 5000))
     .Do(CreateWebSite)
     .AddTask(x => x.IisTasks().ControlAppPoolTask("Example app pool", ControlApplicationPoolAction.Start));
 }
Ejemplo n.º 3
0
 public void Deploy(ITarget target, string deployPath, string backupFullFilePath)
 {
     target.AddTask(x => x.ControlService(StandardServiceControlCommands.Stop, WindowsServiceName)
                    .DoNotFailOnError())
     .Do(UnzipPackage)
     .Do(Backup, deployPath, backupFullFilePath, x => { x.DoNotFailOnError(); })
     .AddTask(x => x.DeleteDirectoryTask(deployPath, false).Retry(30, 5000))
     .AddTask(x => x.CreateDirectoryTask(deployPath, false))
     .AddTask(x => x.CopyDirectoryStructureTask(@"Deploy\\WindowsService", deployPath, true).NoLog()
              .Retry(30, 5000))
     .AddTask(x => x.ControlService(StandardServiceControlCommands.Start, WindowsServiceName)
              .DoNotFailOnError());
 }
Ejemplo n.º 4
0
 public void TestTargets2(ITarget target)
 {
     target.AddTask(x => x.CompileSolutionTask());
 }
Ejemplo n.º 5
0
 public void TestTargets(ITarget target, string param, string param2)
 {
     target.AddTask(x => x.CompileSolutionTask(param, param2));
 }
        public void Deploy(ITarget target, string deployPath, string backupFullFilePath, string appPoolName, string prepConfEvniroment, bool importN2Table, string dbConnectionString)
        {
            var    webConfigPath          = Path.Combine(deployPath, "web.config");
            var    webConfigOldBackupPath = @"Backup\Web\web.config";
            string oldN2TablePrefix       = "N/A";

            oldN2TablePrefix = GetOldN2TablePrefix(target, webConfigPath, oldN2TablePrefix, webConfigOldBackupPath);

            target.Group(t =>
            {
                t.Do(SwitchStatusForLb, prepConfEvniroment, options => { options.DoNotFailOnError(); })
                .AddTask(x => x.Sleep(5000))
                .AddTask(x => x.IisTasks().ControlAppPoolTask(appPoolName, ControlApplicationPoolAction.Stop))
                .DoAsync((Action <ITaskContext>)UnzipPackage)
                .DoAsync((Action <ITaskContext, string, string>)Backup, deployPath, backupFullFilePath)
                .AddTask(x => x.RunProgramTask(@"Packages\WebA[[\prepconf.bat")
                         .WithArguments(prepConfEvniroment)
                         .WorkingFolder("Packages\\WebApp"))
                .Do(DiffAllConfigs, deployPath)
                .AddTask(x => x.CopyFileTask(webConfigPath, webConfigOldBackupPath, true).DoNotFailOnError())         //// web config must be backed up because next deploys might depend on it if current deploy fails.
                .AddTask(x => x.DeleteDirectoryTask(deployPath, false).Retry(20, 5000))
                .AddTask(x => x.CreateDirectoryTask(deployPath, false).DoNotFailOnError())
                .AddTask(x => x.CopyDirectoryStructureTask(@"Packages\\Webapp", deployPath, true)
                         .Retry(5, 5000).NoLog());
            },
                         onFinally: c =>
            {
                c.Tasks().IisTasks().ControlAppPoolTask(appPoolName, ControlApplicationPoolAction.Start)
                .Retry(10, 15000).Execute(c);
                if (OnlyN2Import)
                {
                    new DoTask2 <string>(SwitchStatusForLb, prepConfEvniroment).Execute(c);
                }
                new DoTask2 <string>(CheckLbStatus, prepConfEvniroment).Execute(c);
            },
                         when: c => !OnlyN2Import);

            //// Package has to be unziped because we need n2 export file
            target.Do(UnzipPackage).When(c => OnlyN2Import);


            if (N2Table == "NoImport")
            {
                importN2Table = false;
                N2Table       = oldN2TablePrefix;
                target.Do(c => { c.LogInfo("No N2Import. N2Table prefix will be set to the value that the old scp had."); }).When((c) => oldN2TablePrefix != "N/A");
                target.Do(c => { c.LogInfo("WARNING: N2 Table prefix is set to N/A. "); }).When((c) => oldN2TablePrefix == "N/A");
            }

            if (N2Table == "DifferentFromCurrent")
            {
                switch (oldN2TablePrefix)
                {
                case "N2":
                {
                    N2Table = "N3";
                    break;
                }

                case "N3":
                {
                    N2Table = "N2";
                    break;
                }
                }
            }

            target.AddTask(x => x.UpdateXmlFileTask(webConfigPath).UpdatePath("//n2/database/@tablePrefix", N2Table));

            if (importN2Table)
            {
                var webBaseUrl = prepConfEvniroment == "Test" ? WebAppBaseUrlTest : WebAppBaseUrlProd;

                target.Do(DeleteN2Tables, dbConnectionString);
                target.Do(ImportN2DataFromXml, webBaseUrl);
            }
            else
            {
                target.Do((c) => c.LogInfo("Skipping n2 import"));
            }

            target.Do(UpdateWebConfig, dbConnectionString, deployPath);
            target.Do(c => { File.Delete(webConfigOldBackupPath); });
        }
Ejemplo n.º 7
0
        public static ITarget DotnetAddEfMigration(this ITarget target, string workingFolder, string migrationName = "default")
        {
            target.AddTask(AddEfMigration(workingFolder, migrationName));

            return(target);
        }
Ejemplo n.º 8
0
        public static ITarget DotnetEfDropDatabase(this ITarget target, string workingFolder)
        {
            target.AddTask(EfDropDatabase(workingFolder));

            return(target);
        }
Ejemplo n.º 9
0
        public static ITarget DotnetRemoveEfMigration(this ITarget target, string workingFolder, bool forceRemove = true)
        {
            target.AddTask(RemoveEfMigration(workingFolder, forceRemove));

            return(target);
        }