使用PowerShell部署数据库项目(.dbproj)

Jac*_*ock 5 sql-server msbuild powershell

我想使用powershell部署数据库项目"database.dbproj"(例如).到目前为止,我尝试使用以下方法部署项目,

$ msbuild ='C:\ Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe'

$ option1 = @('/ t:reBuild,deploy/p:TargetConnectionString ="Data Source =(local)\ SQL2008R2; Integrated Security = True; Pooling = False;"/ p:TargetDatabase = test"C:\ TEMP\SVN\6000 \数据库\ Database.dbproj"')

&$ msbuild $ option1

$ test1 = @('/ target:Build,deploy','C:\ TEMP\SVN\6000 \Database\Database.dbproj','/ property:TargetConnectionString = Data Source =(local)\ SQL2008R2; Integrated Security =真;池= FALSE;"", '/属性:TargetDatabase =试验')

&$ msbuild $ test1

$ test2 = $ msbuild +""+ $ option1

Invoke-Expression $ test2

但在所有情况下它都没有做任何事情.我的意思是如果我调试代码然后我可以看到这个指针到达这个命令然后只是移动到下一行命令而不做任何事情.我有类似的批处理脚本,它工作得很好.所以我确信这是导致这个问题的一些noob错误.我在这做什么错了?

谢谢,杰克

Mus*_*idi 5

请尝试以下方法:

Start-Process -FilePath "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" -ArgumentList "/t:reBuild,deploy /p:TargetConnectionString=`"Data Source=(local)\SQL2008R2;Integrated Security=True;Pooling=False;`" /p:TargetDatabase=test `"C:\TEMP\SVN\6000\Database\Database.dbproj`""
Run Code Online (Sandbox Code Playgroud)