Reputation: 1120
The environment:
Using the SqlPackage Action "Publish", the script for deployment is generated using the following variables based on the target database's defaults:
:setvar DefaultDataPath "H:\YourServerDefault"
:setvar DefaultLogPath "H:\YourServerDefault"
I would like to override these locations to land in a specific pair of directories where we have some external encryption configured.
I have attempted to override these SQLCMD values in a couple ways:
Override on the command line:
SQLPackage /Action:Publish /SourceFile:./Db.dacpac /Profile:./MyProfile.publish.xml /Variables:DefaultDataPath=H:\MyNewLocation
Add an override in the publish profile (snippet below):
<ItemGroup>
<SqlCmdVariable Include="DefaultDataPath ">
<Value>H:\YourServerDefault</Value>
</SqlCmdVariable>
</ItemGroup>
While I can use either technique to override my own defined SQLCMD variables, the built in ones like DefaultDataPath and DefaultLogPath are ignored.
Is there a way to override these values when publishing with SqlPackage?
Upvotes: 3
Views: 3686
Reputation: 8110
There is no built in support in SqlPackage but you can do this using a deployment contributor. Take a look at the DbLocationModifier sample on GitHub that solves exactly this issue. To actually use this, you need to:
For more information about contributors and how to use them you can read the tutorial I wrote or read the walkthroughs on MSDN.
Disclosure: I work on the SQL Server tools team.
Upvotes: 3