dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Publish-DbaDacPackage not respecting DatabaseScriptPath property when provided within -DacOption

Open chadbaldwin opened this issue 3 years ago • 0 comments

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

N/A - no error received

When providing a DacOption object, it seems the DatabaseScriptPath property is getting overridden with a default by dbatools.

Steps to Reproduce

$options = New-DbaDacOption -Type Dacpac -Action Publish
$options.GenerateDeploymentScript = $true
$options.DatabaseScriptPath = "C:\deployscript.sql"
Publish-DbaDacPackage -SqlInstance ServerName -Database MyDatabase -Path 'C:\MyDatabase.dacpac' -DacOption $options

Please confirm that you are running the most recent version of dbatools

1.1.120

Other details or mentions

Looking at the source for this function, it seems the same issue would also exist for MasterDbScriptPath

For reference, this is the part of the function in question. It seems to override any existing values, rather than only populating with a default when necessary: https://github.com/dataplat/dbatools/blob/6cae0dd18bda3ad8efd60404c2d05b402cc4a785/functions/Publish-DbaDacPackage.ps1#L279-L282

What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe)

PowerShell Host Version

PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

SQL Server Edition and Build number

N/A

.NET Framework Version

.NET 6.0.6

chadbaldwin avatar Aug 06 '22 20:08 chadbaldwin

Thank you for the report @chadbaldwin. @nvarscar do you have time to take a look? 🙇🏼

potatoqualitee avatar Aug 15 '22 11:08 potatoqualitee