Update DacFx deploy and generate script with options (#998)

* update deploy and generate script to accept deployment options

* add tests

* add test with option set to true
This commit is contained in:
Kim Santiago
2020-07-29 13:43:38 -07:00
committed by GitHub
parent 9d52370df0
commit 788dc31081
5 changed files with 181 additions and 7 deletions

View File

@@ -4,6 +4,7 @@
//
using System.Collections.Generic;
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.SchemaCompare.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.DacFx.Contracts
{
@@ -21,6 +22,11 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx.Contracts
/// Gets or sets SQLCMD variables for deployment
/// </summary>
public IDictionary<string, string> SqlCommandVariableValues { get; set; }
/// <summary>
/// Gets or sets the options for deployment
/// </summary>
public DeploymentOptions DeploymentOptions { get; set; }
}
/// <summary>

View File

@@ -4,6 +4,7 @@
//
using System.Collections.Generic;
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.SchemaCompare.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.DacFx.Contracts
{
@@ -26,6 +27,11 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx.Contracts
/// Gets or sets SQLCMD variables for script generation
/// </summary>
public IDictionary<string, string> SqlCommandVariableValues { get; set; }
/// <summary>
/// Gets or sets the options for deployment
/// </summary>
public DeploymentOptions DeploymentOptions { get; set; }
}
/// <summary>

View File

@@ -5,6 +5,7 @@
using Microsoft.SqlServer.Dac;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.DacFx.Contracts;
using Microsoft.SqlTools.ServiceLayer.SchemaCompare;
using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.DacFx
@@ -25,7 +26,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx
public override void Execute()
{
DacPackage dacpac = DacPackage.Load(this.Parameters.PackageFilePath);
DacDeployOptions options = this.GetDefaultDeployOptions();
DacDeployOptions options = this.Parameters.DeploymentOptions != null ? SchemaCompareUtils.CreateSchemaCompareOptions(this.Parameters.DeploymentOptions) : this.GetDefaultDeployOptions();
if (this.Parameters.SqlCommandVariableValues != null)
{

View File

@@ -2,15 +2,16 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlServer.Dac;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.DacFx.Contracts;
using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Microsoft.SqlTools.Utility;
using System;
using Microsoft.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using Microsoft.SqlServer.Dac;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.DacFx.Contracts;
using Microsoft.SqlTools.ServiceLayer.SchemaCompare;
using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.DacFx
{
@@ -35,7 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx
PublishOptions publishOptions = new PublishOptions();
publishOptions.GenerateDeploymentReport = this.Parameters.GenerateDeploymentReport;
publishOptions.CancelToken = this.CancellationToken;
publishOptions.DeployOptions = this.GetDefaultDeployOptions();
publishOptions.DeployOptions = this.Parameters.DeploymentOptions != null ? SchemaCompareUtils.CreateSchemaCompareOptions(this.Parameters.DeploymentOptions) : this.GetDefaultDeployOptions();
if (this.Parameters.SqlCommandVariableValues != null)
{