how do I target azure v12 database for sqlproj from the build command - azure-sql-database

We have a sqlproj that targets SQL 2014 locally. The build and publish work as expected from Visual Studio.
Now we are trying to build and deploy the database project to Azure Database v12 using VS Online. We are getting errors stating the SSDT targets the wrong database. This makes sense as Azure Database and SQL 2014 surpport different features and produce different warnings/errors. Every article/post we have found online shows how to change the target platform from the GUI at design time.
Our assumption is the platform can be targeted at build time, same as changing the target platform of a class library. However we are not able to locate a list of available arguments for a sqlproj targetplatform.
Does anyone have a link or know the key=value property to set for the VS Online build parameters?
Thank you

The value is stored in DSP property of project, so you can specify /p:DSP=Microsoft.Data.Tools.Schema.Sql.SqlAzureV12DatabaseSchemaProvider MSBuild argument in Visual Studio Build task.

As long as everything in your project can be deployed then:
/p:AllowIncompatiblePlatform=true

Related

Can´t build .net core project with a database project. Error MSB4019

I have a new .net Core 2.0 Web API project (In Visual Studio 2017 Version 15.3.5) where I can´t build the solution if I add a new database project.
error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.0.0\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
I have tried all kinds of solutions
Installed almost everything missing from the Visual Studio Installer
Installed Visual Studio Build Tools 2017
Repaired Visual Studio
Without luck I tried to find Microsoft.Data.Tools.Schema.SqlTasks.targets file on C:\ to the add reference to it in the project file (I then don´t know if that works while building the solution in VSTS).
So why can I add a database project to a normal API project and everything works just fine but not to a .net core one?
Do database projects not work with .net Core? I have searched for information on this but sorry I just can´t find it.
I´m not sure what to do. Hope somebody can help.
Ok I managed to find the Microsoft.Data.Tools.Schema.SqlTasks.targets file on my computer.
I then needed to unload the project and edit it
There I changed this line
<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>
to the hardcoded path of my file
<SSDTExists Condition="Exists('C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>
And now it builds on my computer and on VSTS.
But why this is like this I don´t know.
I was having the exact same issue building a SQL Server project on an Azure DevOps CI/CD pipeline, and locally on VS Code. On Azure DevOps none of the pre-built build tasks would work for me, and locally I could only compile the SQL Server project on Visual Studio, which was annoying. Your solution didn't work for me, after doing what you suggest, I would get a .dll missing error, related with the first error.
I solved this by avoiding to add a SQL Server project to the solution.
I achieved this by using an MSBuild SDK, capable of producing a SQL Server Data-Tier Application package (.dacpac) from the set of SQL scripts. By adding this second project to the solution, I managed to continue taking advantage of linking the project to a live database through SQL Server Object Explorer on Visual Studio. I gave a more detailed explanation about my implementation in this answer.

How to create a database project in Visual Studio 2013

I'm migrating a solution which contains some C# projects from Visual Studio 2008 to VS2013. The migration went fine, with a few adjustments, but there's also a .dbp project (database project, from VS2008), which refuses to migrate / load in VS2013.
The closest project type I found in this newer version is "SQL Server Database Project", I've created one and added my existing .sql script files, but this project type (.sqlproj) appears to be something different. For example, VS 2008's "database project" does not build. Also, I had a hard time trying to add a reference to my existing SQL database running under SQLExpress.
I've also set BuildAction = None to all my script files, and now I can open each of them manually and execute. But still, I'd like to select multiple files and execute them all at once. Seems I'm missing something.
So, is there a way to accomplish that?
I suggest you look at the following article to convert the dbp to dbproj: MSDN
And after that look at the following link to convert dbproj to sqlproj: Tentacle Software Blog

Build/Deploy SSRS with TFS 2010

I am trying to build and deploy an SSRS project (rptproj) but MSBuild does not support this project type. What can I use to build and deploy this project?
I looks like I can use RS.EXE and Dev Env. What are the benefits of each?
It actually is recommended to install Visual Studio on the TFS Build machine to support building various types of projects that MSBuild alone does not support. You don't have to worry about licensing because as long as you have a Visual Studio license then you can put it on all of your machines.
You can find more details here.

Visual Studio 2010 Database Project Installer / Install script

I have been using a database project in visual studio 2010 to create a database. Visual Studio makes this process really easy to deploy the database and deploy updates. The issue I have is how I can get visual studio to create a script that will build the database that I can use on a QA or production system.
I thought that building the project would create a SQL file that did this but this does not seem to be true. Can someone please advise on how I can do this or what simple step I am clearly missing.
As strange as it may sound, Visual Studio does not create a SQL file to deploy your database when you perform a Build.
Instead, this occurs at Deploy time. The reason behind this lies in the way that Visual Studio makes changes to the database that you're deploying to: in order to change your database, it must first compare the project model (as defined in the files contained within the .dbproj) with that of the existing database schema to determine what changes you have made since the database was last deployed.
You then have the choice of manually executing the SQL script produced using the SQLCMD command-line utility (or through SSMS in SQLCMD mode), or alternately you can configure your Visual Studio Database Project to execute the script if you specify the following Deploy Action in project settings:
Generate a deploy script (.sql) and deploy to the database
Note that you will need to provide a connection string in project settings so VS knows where to deploy to.
When you get to the stage where you want to deploy to a QA or PROD environment, you have a couple of options:
Deploy directly within Visual Studio. In addition to the standard Debug and Release configurations that you get when you first create your Database Project, you can also create your own configurations which you could use to deploy to your QA and PROD environments (i.e. potentially with a different connection string/target database name).
Deploy from a Build Server. Install Visual Studio on a separate machine and call MsBuild against your .dbproj/.sln file with the Build and Deploy targets specified along with the appropriate connection properties.
Doug Rathbone has written a great blog post on subject if you want to learn more:
http://www.diaryofaninja.com/blog/2011/06/23/compare-amp-update-database-schemas-right-within-your-ide--part-2-automation-with-teamcity

Best practices or tools for installing a SQL Server database

Best practices or tools for installing a SQL Server database
I have a SQL Server database designed with the SQL Server GUI database editor/Visual Studio.
What is the best way to "install" that database on other systems. Said another way how should I ship this thing?
I know I can save the scripts and set the primary/foreign keys with T-SQL but I suspect their is something better. I guess you could have people restore from backup but that does not seem very professional.
What other choices are there and what are the pluses and minuses?
For it to look professional make a small setup program.
You currently have sql scripts that you use to create your db.
Make yourself a small xml file that contains the path to your scripts.
Create a small c# library that will connect to the db server, and run those scripts.
You can test this outside of the setup, in visual studio, then add it to the setup like this.
To do this from your setup all you have to do is put the xml file in a component so it is deployed,
And create a custom action in your setup, that will call your C# lib, read the xml and run the scripts on the sql server to create your db.
Also, from a setup program it's easy to set a registry key to identify the version of the your db that you just installed.
The minuses and pluses: It's a bit of work to start with, but with this you'll have all the ground work done to handle upgrades automatically later on, to do so, just add an upgradeScript section to your xml, an attribute called version for each upgrade script, and simply compare it against the version of the db you have save in the registry. The advantage is this way it can easily scale with your project.
My previous answer is mostly to keep full control on the deployment and upgrades.
I have searched for more built-in and streamlined solution that goes along with the DB designer mode you have used.
I found that in the version Studio 2005 Team Edition for Database Professionals of visual studio there might be deployment features.
Build and Deployment
You've seen that you can generate a
T-SQL update script manually via the
Schema Comparison tool. However, as
part of the build process, DB Pro
edition can generate a complete script
for deploying your database project.
This deployment script can do either a
complete build or an incremental
update. The build process can even
consolidate all of your pre- and
post-deployment scripts into one
complete deployment script. You can
deploy the script via the Build |
Deploy Selection command right from
within Visual Studio 2005. Under
project properties, you will find a
number of options to control and
adjust the build process. The Build
tab contains the core settings, such
as Target connection, Target database
name, and Block incremental deployment
if data loss might occur. You'll note
there is also a Build Events tab that
you can use to type pre- or post-build
event commands. DB Pro edition uses
MSBuild for its build process and
supports integration with Team Build
if you're using Team Foundation
Server.