How to send a connection string as a parameter to MsBuild to perform SQL Schema Compare? -
the sql server data tools team blog mentions possible use msbuild perform schema comparison of 2 dacpacs or databases. however, not mention how pass in connection string source , target database. if set parameter /p:source="my connection string" error:
msbuild : error msb4177: invalid property. name "initial catalog" contains invalid character " ".
the command-line powershell script sends msbuild is:
msbuild ".\schemacompare.proj" /t:sqlschemacompare /p:source="$sourceconnstring" /p:target="$targetconnstring" /p:xmloutput="$schemacomparereportpath"
where schemacompare.proj contains content suggested on sql server data tools team blog
it turns out have replace semicolons in connection string %3b
, so:
$sourceconnstring = $sourceconnstring.replace(";", "%3b")
explanation: prevents delimiter collisions between sql server connectionstring
value , msbuild /p
(a.k.a. /properties
) value contains it. absent url-encoding, msbuild tokenize connectionstring
on semicolons rather passing on whole value intact (for sql server client libraries tokenize). applies properties
attribute of msbuild task.
references:
Comments
Post a Comment