How can I script to deploy a Visual Studio database project?

How can I script to deploy a Visual Studio database project?

I have a DB project in visual studio and I would like to use it to deploy to remote machines using a script. I notice that when I "deploy" from visual studio, it generates a .sql file.

I intercepted this file and tried to run it from the command line using osql.exe, but I had no success. Should this work, is there a better way to deploy the database programmatically from a database project, maybe by referencing in another project and calling a method to deploy it?

+4
source share
2 answers
MSBuild /target:SQLBuild MyProjectName.dbproj 

Performs an assembly-only action. It creates only one database project named MyProjectName.dbproj. The project properties in the .dbproj file are used to build the build script.

 MSBuild /target:Deploy /property:TargetDatabase=UpdatedTargetDatabase;TargetConnectionString="Data Source=(local)\SQLEXPRESS;Integrated Security=True;Pooling=False" MyProjectName.dbproj 

Deploys the database project, overriding the name of the target database and the connection string.

+4
source

For me in Vs2010 this file created a file

MSBuild /target:Deploy MyProjectName.dbproj

another option

MSBuild /target:Build;Deploy MyProjectName.dbproj

additional information found at http://ishan-patel.blogspot.com/2012/04/create-single-database-deployment.html

0
source

Source: https://habr.com/ru/post/1309610/


All Articles