private static void PrintInfo(Argument arg, string env, Settings settings, Project project) { Console.WriteLine("Deployment information:"); Console.WriteLine("-------------------------------------"); Console.WriteLine("Environment:\t" + env); Console.WriteLine("Project path:\t" + project.Environment[env].ProjectPath); Console.WriteLine("Project file:\t" + project.ProjectName); Console.WriteLine("Project type:\t" + DeployStrategyFactory.GetStrategyName(project.ProjectType)); Console.WriteLine("Deploy path:\t" + project.Environment[env].DeploymentPath); Console.WriteLine("Deploy profile:\t" + project.Environment[env].DeploymentProfile); Console.WriteLine("Purge dir:\t" + (arg.PurgeDirectory ? "Yes" : "No")); Console.WriteLine("Backup files:\t" + (arg.Backup ? "Yes" : "No")); if (arg.Backup) { Console.WriteLine("Backup path:\t" + settings.BackupPath); } Console.WriteLine("-------------------------------------"); }
public static void Main(string[] args) { try { Argument arg = null; // There have to be some arguments if (args == null || args.Length == 0) { PrintUsage(); return; } // Parse and gather arguments arg = new Argument(new Arguments(args)); // Display version info if (arg.DisplayVersion) { PrintVersion(); return; } // Parse global settings XML file Settings settings = XmlParser.ParseSettings("settings.xml", arg); // Parse project XML file Project project = XmlParser.ParseProject(arg.ConfigFile, settings, arg); // Get the deployment strategy based on the project type IDeployStrategy strategy = DeployStrategyFactory.GetStrategyFromType(project.ProjectType); foreach (var env in arg.DeploymentEnvironment) { // Check for confirmation if (arg.Confirmation) { Confirm(arg, settings, project, env); } // Do backup if (arg.Backup) { Backup(settings, project, env); } // Do the actual deployment var exitCode = strategy.Deploy(arg, settings, project, env); // Check if there was an error if (exitCode > 0) { Console.WriteLine("Deployment failed with exit code " + exitCode + ", quitting..."); Environment.Exit(exitCode); } // No error, display deployment information else { Console.WriteLine("Build & Deployment successful!"); PrintInfo(arg, env, settings, project); } } } catch (Exception ex) { PrintText(ex.Message); // Exit with an error Environment.Exit(1); } }