From f8783b86f2e37ae3c59931cff3f59cf579f14dfb Mon Sep 17 00:00:00 2001 From: Anthony Brown Date: Tue, 20 Sep 2016 16:12:10 +0100 Subject: [PATCH] Added means of supplying additional sqlpackage.exe configuration properties --- src/app/FakeLib/Sql.DacPac.fs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/FakeLib/Sql.DacPac.fs b/src/app/FakeLib/Sql.DacPac.fs index a26291967ea..12d19fe4977 100644 --- a/src/app/FakeLib/Sql.DacPac.fs +++ b/src/app/FakeLib/Sql.DacPac.fs @@ -32,7 +32,9 @@ type DeployDbArgs = { /// Drops objects in the destination that do not exist in the source. Defaults to false. DropObjectsNotInSource : bool /// Recreates the database from scratch on publish (rather than an in-place update). Defaults to false. - RecreateDb : bool } + RecreateDb : bool + /// Additional configuration parameters required by sqlpackage.exe + AdditionalSqlPackageProperties : (string * string) list } let validPaths = let getSqlVersion (path:string) = path.Split '\\' |> Array.item 3 |> int @@ -57,7 +59,12 @@ let defaultDeploymentArgs = Timeout = 120 BlockOnPossibleDataLoss = true DropObjectsNotInSource = false - RecreateDb = false } + RecreateDb = false + AdditionalSqlPackageProperties = [] } + +module PropertyKeys = + /// When creating a new SQL Azure database, specifies the database service tier to use e.g. S2, P1 + let sqlAzureDbSize = "DatabaseServiceObjective" let private generateCommandLine args = let action, outputPath = @@ -73,6 +80,11 @@ let deployDb setParams = let args = setParams defaultDeploymentArgs let action, outputPath = generateCommandLine args.Action + let additionalParameters = + args.AdditionalSqlPackageProperties + |> List.map (fun (key, value) -> sprintf "/p:%s=%s" key value) + |> String.concat " " + if System.String.IsNullOrWhiteSpace args.SqlPackageToolPath then failwith "No SqlPackage.exe filename was given." @@ -81,7 +93,7 @@ let deployDb setParams = shellExec { Program = args.SqlPackageToolPath - CommandLine = sprintf """/Action:%s /SourceFile:"%s" /TargetConnectionString:"%s" %s /p:BlockOnPossibleDataLoss=%b /p:DropObjectsNotInSource=%b /p:CommandTimeout=%d /p:CreateNewDatabase=%b""" action args.Source args.Destination outputPath args.BlockOnPossibleDataLoss args.DropObjectsNotInSource args.Timeout args.RecreateDb + CommandLine = sprintf """/Action:%s /SourceFile:"%s" /TargetConnectionString:"%s" %s /p:BlockOnPossibleDataLoss=%b /p:DropObjectsNotInSource=%b /p:CommandTimeout=%d /p:CreateNewDatabase=%b %s""" action args.Source args.Destination outputPath args.BlockOnPossibleDataLoss args.DropObjectsNotInSource args.Timeout args.RecreateDb additionalParameters WorkingDirectory = "" Args = [] }