2015-07-10 17 views
2

我试图使用发布的MSBuild从我(的TeamCity)建立服务器.sqlproj项目。我使用的是.publish.xml设置了大部分的发布设置,但要指定在命令行上的连接字符串,所以我可以把它安全地存储在TeamCity的性能。SSDT发布不使用连接字符串从MSBuild的命令行

但是,似乎MSBuild根本不使用命令行上指定的连接字符串,并坚持使用.publish.xml中的连接字符串。我尝试将它从XML中清除并清空它,但MSBuild并不那么喜欢它,并且吐出了Before you can deploy a database, you must specify a connection string in the project properties or at a command prompt.,这当然正是我想要做的......

用于发布完整的命令如下:

msbuild /t:Build;Publish /p:SqlPublishProfilePath="c:\path\to\profile.publish.xml" /p:Publish_TargetConnectionString="the connection string" "c:\path\to\project.sqlproj"

我使用/p:TargetConnectionString/p:SqlPublishProfilePath="c:\path\to\profile.publish.xml";Publish_TargetConnectionString="the connection string"也尝试过,但都无济于事。

.publish.xml如下:

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <PropertyGroup> 
    <IncludeCompositeObjects>True</IncludeCompositeObjects> 
    <TargetDatabaseName><!-- snip --></TargetDatabaseName> 
    <DeployScriptFileName><!-- snip -->.sql</DeployScriptFileName> 
    <TargetConnectionString><!-- snip snip --></TargetConnectionString> 
    <ScriptDatabaseOptions>False</ScriptDatabaseOptions> 
    <BlockOnPossibleDataLoss>False</BlockOnPossibleDataLoss> 
    <DeployDatabaseInSingleUserMode>False</DeployDatabaseInSingleUserMode> 
    <ProfileVersionNumber>1</ProfileVersionNumber> 
    </PropertyGroup> 
</Project> 

SSDT是我可以从微软下载今天的最新版本。

有没有人得到这个工作?

+2

我曾与MSBuild任务它可能只是我虽然不同的问题。我要做的就是使用的MSBuild直接调用sqlpackage.exe因为你有更多的控制,它似乎更好地工作 –

+1

[见这个答案](http://stackoverflow.com/a/8376809/65775)如何使用sqlpackage 。可执行程序。 – Keith

回答

0

正如上面说的意见,我使出使用的MSBuild建设的.dacpac和sqlpackage.exe将其发布到SQL Server,并且工作正常。