Add support for getting DacFx deploy options from a publish profile (#995)

* add support for getting options from a publish profile

* update comments

* set values for default options if they aren't specified in the publish profile

* addressing comments
This commit is contained in:
Kim Santiago
2020-07-27 17:52:15 -07:00
committed by GitHub
parent 0014687343
commit 1a93404e54
6 changed files with 234 additions and 9 deletions

View File

@@ -2,12 +2,9 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.IO;
using System.Threading.Tasks;
using Microsoft.SqlServer.Dac;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare.Contracts
{
@@ -241,6 +238,52 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare.Contracts
}
public DeploymentOptions(DacDeployOptions options)
{
SetOptions(options);
}
/// <summary>
/// initialize deployment options from the options in a publish profile.xml
/// </summary>
/// <param name="options">options created from the profile</param>
/// <param name="profilePath"></param>
public async Task InitializeFromProfile(DacDeployOptions options, string profilePath)
{
// check if defaults need to be set if they aren't specified in the profile
string contents = await File.ReadAllTextAsync(profilePath);
if (!contents.Contains("<AllowDropBlockingAssemblies>"))
{
options.AllowDropBlockingAssemblies = true;
}
if (!contents.Contains("<AllowIncompatiblePlatform>"))
{
options.AllowIncompatiblePlatform = true;
}
if (!contents.Contains("<DropObjectsNotInSource>"))
{
options.DropObjectsNotInSource = true;
}
if (!contents.Contains("<DropPermissionsNotInSource>"))
{
options.DropPermissionsNotInSource = true;
}
if (!contents.Contains("<DropRoleMembersNotInSource>"))
{
options.DropRoleMembersNotInSource = true;
}
if (!contents.Contains("<IgnoreKeywordCasing>"))
{
options.IgnoreKeywordCasing = false;
}
if (!contents.Contains("<IgnoreSemicolonBetweenStatements>"))
{
options.IgnoreSemicolonBetweenStatements = false;
}
SetOptions(options);
}
public void SetOptions(DacDeployOptions options)
{
System.Reflection.PropertyInfo[] deploymentOptionsProperties = this.GetType().GetProperties();