问题
Is it possible for me to specify the Target Platform (SQL Server 2014, SQL Server 2016, Azure, etc) in a publish profile? I have a database project that I sometimes deploy to a local SQL Server 2016 instance, and other times deploy to an Azure SQL database. I would like to just specify 2 different publish profiles and have the target platform be changed on the fly at that time. Is this possible?
回答1:
Azure, MSSQL 2014, MSSQL 2016 have different limitations and requirements to Database Project.
Let's imagine: You are using FILESTREAM in MSSQL 2014 and will use in MSSQL 2016. And your FILESTREAM is described in Database Project. Now, you add Azure support in your solution and want to deploy database. But, Azure does not support FILESTREAM.
So you can't have one database project in this case. You need to select minimal supported target project:
In this case, it's Microsoft Azure SQL Databse (or V12). When you select minimal supported target platform, you can be sure that all "higher" versions will support it.
Assume, that Azure is some subset of MSSQL Server features. And Database Project validates all using features across target platform.
If you afraid that selecting Microsoft Azure SQL Databse as target platform you won't able to publish to MSSQL Server 2016 - no problem, it will work.
If you need to use different connection strings or publish settings - create different publish profiles.
回答2:
You can use msbuild and rebuild to generate dacpac. We can change the target platform in the project using powershell to make automated way.
msbuild SlnFolders.sln /t:NotInSolutionfolder:Rebuild;NewFolder\InSolutionFolder:Clean
From there we can do dacpac deployment with publish profile.
来源:https://stackoverflow.com/questions/38854623/visual-studio-database-project-target-platform-in-publish-profile