We have started using local SQL Servers (SQL 2012) for development. We have a tool that calls MSBUILD to deploy a SQL Project (.sqproj) to either our local, dev & test databases.

A requirement has come up where we want to use that tool to deploy to other local databases - it's a rare thing to do but needed.

We have setup a .publish.xml file for each normal environment (dev.publish.xml, test.publish.xml, local.publish.xml, where local points to (local)\SQL2012).

We normally run:

msbuild.exe /t:build;publish /p:SqlPublishProfilePath="Local.publish.xml" "c:\workspaces\greg\...\databaseProject.sqlproj"

That works fine as it takes the connection string from the local.publish.xml file and deploys the sql project to our local database.

I'm not sure how to overwrite the publish file to make it point to a different database

I've tried

msbuild.exe /t:build;publish /p:SqlPublishProfilePath="Local.publish.xml" /p:TargetConnectionString="Data Source=SomeOtherPC\SQL2012;Integrated Security=True;Pooling=False" "c:\workspaces\greg\...\databaseProject.sqlproj"

but it still points to (local)\sql2012 instead of SomeOtherPC\SQL2012

有帮助吗?

解决方案

Create a different publish profile for this and populate it with the required details (SomeOtherPC, SQL 2012, etc.)

SomeOtherPC.publish.xml

And pass that as the paramter to MSBuild

msbuild.exe /t:build;publish /p:SqlPublishProfilePath="SomeOtherPC.publish.xml"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top