static int DeployDatabase(DeployOptions deployOptions) { var connectionString = deployOptions.ConnectionString; EnsureDatabase.For.SqlDatabase(connectionString); var ungrader = DeployChanges.To.SqlDatabase(connectionString) .WithScriptsAndCodeEmbeddedInAssembly(Assembly.GetExecutingAssembly(), (scriptName) => scriptName.StartsWith("DbUp.Sample.Scripts")) .WithTransaction() .LogToConsole() .Build(); var result = ungrader.PerformUpgrade(); if (!result.Successful) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(result.Error); Console.ResetColor(); return(-1); } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Database Created Successfully!"); Console.ResetColor(); if (deployOptions.SeedData) { return(SeedDatabase(connectionString)); } return(0); }
[Fact] // issue: https://github.com/dotnet/command-line-api/issues/1365 public void Binder_does_not_match_by_substring() { var rootCommand = new RootCommand { new Option <string>( new[] { "-b", "--bundle" }, "the path to the app bundle to be installed"), new Option <string>( new[] { "-1", "--bundle_id", "--bundle-id" }, "specify bundle id for list and upload") }; DeployOptions boundOptions = null; rootCommand.Handler = CommandHandler.Create <DeployOptions>(options => { boundOptions = options; return(0); }); rootCommand.Invoke("-1 value"); boundOptions.Bundle.Should().Be(null); boundOptions.BundleId.Should().Be("value"); }
/// <remarks/> public void deployAsync(byte[] ZipFile, DeployOptions DeployOptions, object userState) { if ((this.deployOperationCompleted == null)) { this.deployOperationCompleted = new System.Threading.SendOrPostCallback(this.OndeployOperationCompleted); } this.InvokeAsync("deploy", new object[] { ZipFile, DeployOptions }, this.deployOperationCompleted, userState); }
static void ConfigureComplete(CommandLineApplication cmd) { var options = DeployOptions.GetOptions(cmd); cmd.Description = "Complete a pending deployment request or create a new, completed deployment"; cmd.Invoke = () => { var processor = _container.GetRequiredService <DeploymentCommandProcessor>(); processor.CompleteAsync(options).Wait(); return(1); }; }
static void ConfigureStart(CommandLineApplication cmd) { var options = DeployOptions.GetOptions(cmd); cmd.Description = "Start a deployment in a pending state. Deployment must be completed or cancelled."; cmd.Invoke = () => { var processor = _container.GetRequiredService <DeploymentCommandProcessor>(); processor.StartAsync(options).Wait(); return(1); }; }
public async Task CancelAsync(DeployOptions options) { var config = new ApiClientConfig(options.ApiKey); var payload = new { version = options.Version, appName = options.App, environmentName = options.Environment }; await _client.PostAsync(config, ROUTE + "/cancel", payload); }
public async Task <List <Deployment> > GetAsync(DeployOptions options) { var config = new ApiClientConfig(options.ApiKey); var deployments = await _client.GetAsync <List <Deployment> >(config, ROUTE); deployments = deployments .Filter(d => d.App, options.App) .Filter(d => d.Environment, options.Environment) .Filter(d => d.Version, options.Version); return(deployments); }
static void ConfigureCancel(CommandLineApplication cmd) { var options = DeployOptions.GetOptions(cmd); cmd.Description = "Cancel a pending deployment"; cmd.Invoke = () => { var processor = _container.GetRequiredService <DeploymentCommandProcessor>(); processor.CancelAsync(options).Wait(); return(1); }; }
public AsyncResult Deploy(byte[] zipFile, Domain.DeployOptions options) { DeployOptions optionMap = new DeployOptions { performRetrieve = options.PerformeRetrive, rollbackOnError = options.RollbackOnError, ignoreWarnings = options.IgnoreWarnings, checkOnly = options.CheckOnly, runTests = options.TestsForRun }; return(_service.deploy(zipFile, optionMap)); }
private static ExitCode Deploy(DeployOptions options) { var scriptPath = NormalizeAndEvaluate(options.Script); var progressWriter = new ConsoleWriter(options.Verbose); var grouper = new OperationGrouper(progressWriter); var nodes = options.Nodes.ToArray(); return((ExitCode)ScriptRunner.Deploy(grouper, scriptPath, nodes, options.Arguments, TimeSpan.FromSeconds(options.TimeoutInSeconds))); }
public Seed( CommonDbContext context, IOptions <DeployOptions> deployOptions, IObjectStorageService objectStorageService, IClusterManagementService clusterManagementService, ILogger <Seed> logger ) { this.dbContext = context; this.deployOptions = deployOptions.Value; this.objectStorageService = objectStorageService; this.clusterManagementService = clusterManagementService; this.logger = logger; }
/// <summary> /// Runs the deploy action. /// </summary> /// <param name="options">CLI options for the deploy action.</param> /// <param name="fromMain">Wheter or not this is called from the main method.</param> /// <returns>CLI return code.</returns> private static int Deploy(DeployOptions options, bool fromMain = true) { DeployAction deployer = new DeployAction(options); int result = deployer.Run(); #if DEBUG if (fromMain == true) { Console.Read(); } #endif return(result); }
public async Task CompleteAsync(DeployOptions options) { var config = new ApiClientConfig(options.ApiKey); var payload = new { name = options.Name, uri = options.Uri, branch = options.Branch, commit = options.Commit, version = options.Version, appName = options.App, environmentName = options.Environment }; await _client.PostAsync(config, ROUTE + "/complete", payload); }
public async Task StartAsync(IProgress <ProgressEventArgs> progress, DeployOptions options, CancellationToken ct) { if (options == null) { options = new DeployOptions(); } if (Status == DeploymentStatus.Error) { progress?.Report(new ProgressEventArgs("Error, deployment not valid")); return; } var selectedTargets = Targets.Where(x => x.Selected); if (options.ExecuteInQueueMode) { foreach (var target in selectedTargets) { await OnEachTarget(progress, target, ct); } } else { var targetsTasks = selectedTargets .AsParallel() .WithDegreeOfParallelism(options.MaxParallelismDegree) .Select(async(target) => await OnEachTarget(progress, target, ct) ); await Task.WhenAll(targetsTasks).ConfigureAwait(false); } ct.ThrowIfCancellationRequested(); if (Targets.Where(x => x.DeploymentState != Database.DatabaseDeploymentState.Success).Count() > 0) { Status = DeploymentStatus.Error; } else { Status = DeploymentStatus.Idle; } }
public Seed( CommonDbContext context, IRoleRepository roleRepository, IGitRepository gitRepository, IRegistryRepository registryRepository, IOptions <DeployOptions> deployOptions, IObjectStorageService objectStorageService, IClusterManagementService clusterManagementService, ILogger <Seed> logger ) { this.dbContext = context; this.roleRepository = roleRepository; this.gitRepository = gitRepository; this.registryRepository = registryRepository; this.deployOptions = deployOptions.Value; this.objectStorageService = objectStorageService; this.clusterManagementService = clusterManagementService; this.logger = logger; }
public async Task GetAsync(DeployOptions options) { var deployments = await _service.GetAsync(options); Write(deployments, options.Pretty); }
public void Deploy(DeployOptions options) { try { var deployableProjects = this.BuildAndPublishSolution( build: !options.ExcludeBuild, parameteriseConnectionStrings: options.ParameteriseConnectionStrings, solutionFile: options.SolutionFile, platform: options.Platform, configuration: options.Configuration); var date = DateTime.Now; var applicationPath = new ApplicationService().GetApplicationDirectory(); var fileService = new FileService(); // Get list of IIS Express sites var iisExpressService = new IisExpressService(this.settings.AppCmdPath); var sites = iisExpressService.GetSites().ToList(); var nextSiteId = sites.Max(s => s.Id) + 1; foreach (var deployableProject in deployableProjects) { this.logger.Information($"Deploying '{deployableProject.ProjectName}'"); // Create a new IIS Express site var newSiteName = Guid.NewGuid().ToString().Replace("-", string.Empty); var newSitePhysicalPath = Path.Combine(applicationPath, $@"output\sites\{newSiteName}"); iisExpressService.AddSite( id: nextSiteId, name: newSiteName, bindings: $"http:/*:80:www.{newSiteName}.com", physicalPath: newSitePhysicalPath); // Copy package folder to application folder var outputProjectFolder = Path.Combine( applicationPath, $@"output\{date:yyyy-MM-dd}\{deployableProject.ProjectName}"); var packageFolder = Path.Combine( deployableProject.Folder, $@"obj\{options.Configuration}\Package"); var outputPackageFolder = Path.Combine(outputProjectFolder, "package"); fileService.CopyFiles(packageFolder, "*.*", outputPackageFolder); // Replace SetParameters.xml values including IIS Application name var pluginsFolder = Path.Combine(applicationPath, "plugins"); var valuesProvider = this.GetValuesProvider(pluginsFolder, options.ValueProviderId); if (valuesProvider == null) { throw new InvalidOperationException( $"The values provider '{options.ValueProviderId}' was not located. " + $"Check that the value provider assemblies are within a subfolder of the plugins folder at '{pluginsFolder}'"); } if (string.IsNullOrWhiteSpace(options.ValueProviderOptions)) { throw new InvalidOperationException("Unexpected empty value provider options provided"); } var setParametersValues = new List <SetParameter> { SetParameter.AsKeyed("IIS Web Application Name", newSiteName) }; var values = valuesProvider.GetValues(options.ValueProviderOptions).ToList(); if (values.GroupBy(v => v.Key).Any(g => g.Count() > 1)) { throw new InvalidOperationException( $"Value provider '{options.ValueProviderId}' returned one or more parameters that do not have distinct keys"); } foreach (var value in values) { var existingParameter = setParametersValues.FirstOrDefault(p => p.Key == value.Key); if (existingParameter != null) { continue; } setParametersValues.Add(value); } var setParametersFilePath = Path.Combine( outputPackageFolder, $"{deployableProject.ProjectName}.SetParameters.xml"); // TODO: make pre/post prefix configurable const string PrePostFix = "__"; var setParametersService = new SetParametersService(); setParametersService.TokenReplacement( setParametersFilePath, setParametersValues, PrePostFix); // Run MSDeploy deploy.cmd to deploy to the new IIS Express site var deployScriptFilePath = $"{setParametersFilePath.Replace("SetParameters.xml", string.Empty)}deploy.cmd"; setParametersService.Deploy(deployScriptFilePath, "/Y /L"); // Copy final Web.config file to deploy folder var webConfigPath = Path.Combine(newSitePhysicalPath, "Web.config"); var deployFolder = Path.Combine(outputProjectFolder, "deploy"); fileService.CopyFile(webConfigPath, deployFolder); // Clean up temporary IIS Express site // fileCopyService.DeleteFolder(newSitePhysicalPath); iisExpressService.DeleteSite(newSiteName); nextSiteId++; } this.logger.Information("Deploy complete."); } catch (Exception exception) { this.logger.Error($"An error occurred deploying: {exception}"); throw; } }
/// <remarks/> public void deployAsync(byte[] ZipFile, DeployOptions DeployOptions) { this.deployAsync(ZipFile, DeployOptions, null); }
public AsyncResult deploy([System.Xml.Serialization.XmlElementAttribute(DataType = "base64Binary")] byte[] ZipFile, DeployOptions DeployOptions) { object[] results = this.Invoke("deploy", new object[] { ZipFile, DeployOptions }); return((AsyncResult)(results[0])); }
public Deployer(DeployOptions deployOptions) { this.options = deployOptions; }
/// <summary> /// Constructor. /// </summary> /// <param name="options">Deploy CLI options.</param> public DeployAction(DeployOptions options) { _options = options; _compiler = new CompileAction(CompileOptions.FromDeployOptions(options), true); _logger = new DeployerLogger(); }
public VersionLogic(ICommonDiLogic commonDiLogic, IOptions <DeployOptions> deployOptions) : base(commonDiLogic) { this.deployOptions = deployOptions.Value; }
public static DeployOptions generateDeployOptions(Organization m_organization) { DeployOptions deployOptions = new DeployOptions(); deployOptions.allowMissingFiles = false; deployOptions.autoUpdatePackage = false; deployOptions.checkOnly = false; deployOptions.ignoreWarnings = false; deployOptions.performRetrieve = false; deployOptions.purgeOnDelete = false; deployOptions.rollbackOnError = true; deployOptions.testLevel = TestLevel.RunLocalTests; if (m_organization.Production != "true") { ConsoleHelper.WriteQuestionLine("Do you want to enable allowMissingFiles ?"); string allowMissingFiles = (Console.ReadLine() == "y") ? "true" : "false"; deployOptions.allowMissingFiles = (allowMissingFiles == "y") ? true : false; ConsoleHelper.WriteQuestionLine("Do you want to enable autoUpdatePackage ?"); string autoUpdatePackage = (Console.ReadLine() == "y") ? "true" : "false"; deployOptions.autoUpdatePackage = (autoUpdatePackage == "y") ? true : false; } ConsoleHelper.WriteQuestionLine("Do you want to enable checkOnly ?"); string checkOnly = (Console.ReadLine() == "y") ? "true" : "false"; deployOptions.checkOnly = (checkOnly == "y") ? true : false; ConsoleHelper.WriteQuestionLine("Do you want to enable ignoreWarnings ?"); string ignoreWarnings = (Console.ReadLine() == "y") ? "true" : "false"; deployOptions.ignoreWarnings = (ignoreWarnings == "y") ? true : false; //ConsoleHelper.WriteQuestionLine("Do you want to enable performRetrieve ?"); //string performRetrieve = (Console.ReadLine()=="y") ? "true" : "false"; //deployOptions.performRetrieve = (performRetrieve=="y") ? true : false; ConsoleHelper.WriteQuestionLine("Do you want to enable purgeOnDelete ?"); string purgeOnDelete = (Console.ReadLine() == "y") ? "true" : "false"; deployOptions.purgeOnDelete = (purgeOnDelete == "y") ? true : false; if (m_organization.Production != "true") { ConsoleHelper.WriteQuestionLine("Do you want to enable rollbackOnError ?"); string rollbackOnError = (Console.ReadLine() == "y") ? "true" : "false"; deployOptions.rollbackOnError = (rollbackOnError == "y") ? true : false; } deployOptions.testLevel = generateTestLevel(); if (deployOptions.testLevel == TestLevel.RunSpecifiedTests) { deployOptions.runTests = generateRunTests(); } ConsoleHelper.WriteQuestionLine("Do you want to enable singlePackage ?"); string singlePackage = (Console.ReadLine() == "y") ? "true" : "false"; deployOptions.singlePackage = (singlePackage == "y") ? true : false; return(deployOptions); }
public async Task CancelAsync(DeployOptions options) => await _service.CancelAsync(options);
public async Task StartAsync(DeployOptions options) => await _service.StartAsync(options);
public async Task CompleteAsync(DeployOptions options) => await _service.CompleteAsync(options);