Why the Msbuild task failed to deploy the database, but Exec is working fine

I am trying to deploy a database project (dbproj format, not the new sqlproj SSDT) ​​inside the automatic processing of the build server. I found the following:

When I call the deployment with the Exec task in my Msbuild script - everything works fine:

<Exec Command="$(MSBuildPath)\MSBuild.exe $(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj 
/t:Deploy 
/p:OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\ 
/p:TargetDatabase=$(DeployDatabaseName)
/p:TargetConnectionString=$(DeployDatabaseConnectionString)" />

But when I try to repeat this using the Msbuild task, it behaves differently:

<MSBuild Projects="$(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj" 
            Targets="Deploy"
            Properties="Configuration=$(BuildConfiguration);
            TargetDatabase=$(DeployDatabaseName);
            TargetConnectionString=&quot;$(DeployDatabaseConnectionString)&quot;;
            OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\;
            " />

The Msbuild task broke into semicolons in DeployDatabaseConnectionString:

<DeployDatabaseConnectionString>Data Source=$(DeployDatabaseServer);Integrated Security=True;Pooling=False</DeployDatabaseConnectionString>

He will report the following:

The name "Integrated Security" contains an invalid character " .

But if I replace the semicolon with the percentage value of the encoding -% 3B - it will be broken inside SqlDeployTask:

error MSB4018: The SqlDeployTask task unexpectedly failed.

TargetConnectionString SqlProject?

PS: exec, msbuild.exe msbuild script -.

+5
1

- Msbuild AdditionalProperties . , \encoding

<ItemGroup>
    <DbProjectToBuild Include="$(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj">
        <AdditionalProperties>Configuration=$(BuildConfiguration)</AdditionalProperties>
        <AdditionalProperties>OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\</AdditionalProperties>
        <AdditionalProperties>TargetDatabase=$(DeployDatabaseName)</AdditionalProperties>
        <AdditionalProperties>TargetConnectionString="Data Source=$(DeployDatabaseServer);Integrated Security=True;Pooling=False"</AdditionalProperties>
    </DbProjectToBuild>
</ItemGroup>        
<MSBuild Projects="%(DbProjectToBuild.Identity)" Targets="Build;Deploy" />
+4

All Articles