Override properties of SQL publish profile with MSBuild

Mark Hellegers 46 Reputation points
2023-11-27T13:14:10.61+00:00

I am trying to override the TargetDatabaseName property of my sql publish file, but I cannot get it to work.

I searched on the internet and I found two (old) Microsoft forum pages where someone gave an answer how it should work, but trying that same solution fails.

The two pages are the following:

https://social.msdn.microsoft.com/Forums/en-US/2b519923-9b62-466d-a9c8-8eb36b8aaf93/override-publish-profile-properties-when-using-the-msbuild-command-line?forum=ssdt

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/02af4353-4f3d-46d7-99d3-52ed9d3f8c2e/profiles-for-multiple-project-when-using-msbuild?forum=ssdt

Has anyone gotten this to work?

I have tried the following commands:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild" /t:publish /p:SqlPublishProfilePath=BuildFile.publish.xml /p:Publish_TargetDatabaseName="BuildDB"

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild" /t:publish /p:SqlPublishProfilePath=BuildFile.publish.xml /p:TargetDatabaseName="BuildDB"

But in both cases I get the error "Deploy error Deploy72002: Property TargetDatabase

must be specified"

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,317 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Greg Low 1,680 Reputation points Microsoft Regional Director
    2024-02-19T22:46:24.0166667+00:00

    Pretty sure the property is called TargetDatabase not TargetDatabaseName like you have in your commands. Have you tried the second option but with "TargetDatabase" in place of "TargetDatabaseName". Note that is the property in the error message.

    0 comments No comments