Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish database project using MsBuild

I have a database project in my solution. It comes with the Local.Datatabase.publish.xml. After building the project, if I double click on the xml file, I'm able to publish the changes to my local database.

I like to automate this process. Using MsBuild, I like to be able to do the same thing.

I've set $msbuild to C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

Unfortunately, $msbuild /t:Publish /p:SqlPublishProfilePath="Local.Database.publish.xml" isn't working.

How can I publish a database project using MsBuild?

like image 760
Ali Khakpouri Avatar asked Nov 02 '25 19:11

Ali Khakpouri


1 Answers

The database projects create bacpac files after build. I can use the sqlpackage, and funnel the connection string in as the parameter.

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\SQLPackage.exe" /a:Publish /TargetConnectionString:"Data Source=(local); Initial Catalog=Database; Integrated Security=SSPI;" /SourceFile:"D:\project\bin\Debug\projectname.dacpac"

enter image description here

like image 175
Ali Khakpouri Avatar answered Nov 04 '25 08:11

Ali Khakpouri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!