BozoJoe
BozoJoe

Reputation: 6442

Generate multiple DACPACs targeting multiple target platforms

I have an SSDT sql server database project of which I want to deploy to both an on premise SQL Server 2016 and SQL Azure.

It appears I can only set the project to target one platform Visual Studio sqlproj properties

I want to be able to build this project (using VSTS build agents) and get multiple DACPAC files, one for each targeted platform.

This question Visual Studio Database project target platform in publish profile may actually be the answer. However I have a feeling I may need the individual DACPACs for the deployment scenario.

Upvotes: 4

Views: 1885

Answers (3)

BozoJoe
BozoJoe

Reputation: 6442

Being that I'm using Visual Studio for the build, I can passed a properties argument to the command line

/p:DSP=Microsoft.Data.Tools.Schema.Sql.SqlAzureV12DatabaseSchemaProvider

which lets me control the Database Schema Provider at build time. Using this at a YAML azure pipeline looks like this:

        - task: VSBuild@1
          inputs:
            solution: '$(build.SourcesDirectory)\mydatabase\whoopie.sqlproj'
            vsVersion: 'latest'
            msbuildArgs: '/p:DSP=Microsoft.Data.Tools.Schema.Sql.SqlAzureV12DatabaseSchemaProvider'

Upvotes: 3

snow_FFFFFF
snow_FFFFFF

Reputation: 3301

Two different approaches I have used for something similar. Both are somewhat tedious, but work:

  1. During your build process, use a script to modify the target platform and assembly name, and then build the project for each target platform you want to support.

  2. Or, create separate database projects for each target platform. However, instead of copying the files into each project, you can link to them from the "master" project. In Visual Studio, you would "Add Existing Item", but then in the add dialog, you choose "Add as Link". Now, you only have to maintain the file in one place, but it is referenced by several different db projects. enter image description here

The most tedious part of #2 is that every time you add a new file to the "master" project, you have to remember to link to it in the others.

Upvotes: 0

Peter Schott
Peter Schott

Reputation: 4681

You don't need individual dacpacs or technically even individual publish profiles. You need to set the option on publish to allow incompatible platforms. That will enable you to publish the DB to any supported platform as long as you're not using features that won't work with that version of SQL Server.

Upvotes: 0

Related Questions