use MSBuild cmd to build and deploy the database project.

时间:2023-03-08 23:23:42
use MSBuild cmd to build and deploy the database project.

You can use the below command to implement it.

SET TargetDBName="Database name"
SET DataBaseServer="DB Server name"
SET DbProjectPath="database project folder" C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /t:Deploy /p:TargetDatabase=%TargetDBName%;TargetConnectionString="Data Source=%DataBaseServer%;User ID=XXX;Password=XXX;Pooling=False" "%DbProjectPath%\DataBaseProjectName.sqlproj"

You may need to add a user on the DB server. Then you can connect the database server with it.

The problem that you may come accross.

Problem 1: error MSB4019: The imported project "C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v10.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correc

t, and that the file exists on disk.

Solution1:

Solution2:

Problem2: Could not load file or assembly 'Microsoft.Data.Tools.Components, Version=10.3.0.0' or one of its dependencies

Solution1:

稍后继续。。。