简体   繁体   中英

VS 2015 MSBuild Deploy Database Project Error

I'm having an issue using VS 2015 MSBuild to deploy a database project via the command line. The issue is I need to be able to use MSBuild with 14.0 only, without VS 2013 installed.

I'm using 14.0 MSBuild at:

C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe

The following works because I also have Visual Studio 2013 installed with the appropriate SQL Server Data Tools:

MSBUILD "C:\\Users\\XYZ\\Desktop\\temp\\Testing\\TestProject\\TestProject.sqlproj" /t:build "/p:Platform=AnyCPU" /t:deploy "/p:TargetConnectionString=Data Source=localhost;IntegratedSecurity=True" /p:TargetDatabase=TestDeployDb /p:Configuration=Release /p:VisualStudioVersion=12.0

However, if I change "VisualStudioVersion" to "14.0 for VS 2015, I get an error:

Deploy error Deploy72002: Unable to connect to master or target server 'TestDeployDb'. You must have a user with the same password in master or target server 'TestDeployDb'.

According to your description, I create a demo and reproduce your issue on my side, you use an incorrect connection string. please modify your command like this:

MSBUILD "C:\Users\XYZ\Desktop\temp\Testing\TestProject\TestProject.sqlproj" /t:build "/p:Platform=AnyCPU" /t:deploy /p:TargetConnectionString="Data Source=localhost;IntegratedSecurity=True" /p:TargetDatabase="TestDeployDb" /p:Configuration=Release /p:VisualStudioVersion=14.0

Credit to Cole Wu for saying my connection string was invalid, but his answer didn't work for me out of the box. For some reason my connection string was* valid for 12.0 but not for 14.0.

The issue ended up being that I had IntegartedSecurity rather than Integrated Security , which broke my command when moving to 14.0

Here is the final that worked:

MSBUILD "C:\Users\XYZ\Desktop\temp\Testing\TestProject\TestProject.sqlproj" /t:build "/p:Platform=AnyCPU" /t:deploy /p:TargetConnectionString="Data Source=localhost;Integrated Security=True" /p:TargetDatabase="TestDeployDb" /p:Configuration=Release /p:VisualStudioVersion=14.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM