You dont mention what version of database projects you are using - i
am assuming it is visual studio 2010 as you are using msbuild v4.
We are using 2008 GDR R2 projects which apart from the msbuild version
are deployed in the same way as 2010 projects. This is what we are
using

    <msbuild>
      <buildArgs>/noconsolelogger /p:TargetConnectionString="Data
Source=target_server;Integrated Security=True;Pooling=False"
/p:TargetDatabase=$(db_name)
/p:OutputPath="$(tfs_root)\ArtifactDirectory\database\$(db_name)"
/p:AutoGenerateBuildScriptName=True
/p:BlockIncrementalDeploymentIfDataLoss=True
/p:DefaultDataPath="E:\Program Files\Microsoft SQL
Server\MSSQL.5\MSSQL\Data\sandbox_databases\\"
/p:DeploymentConfigFile="..\..\databases\sandbox\properties.sandbox\sandox.sqldeployment"
/p:IgnoreColumnCollation=True /p:UseSandboxSettings=False
/p:IgnoreFileAndLogFilePath=True /p:DeployToDatabase=True</buildArgs>
      
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
      
<logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,$(tfs_root)\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
      <projectFile>$(db_proj_name).dbproj</projectFile>
      <targets>clean;build;deploy</targets>
      <timeout>15000</timeout>
      <workingDirectory>$(tfs_root)\tfs\jld\release\sql
server\databases\$(db_name)</workingDirectory>
    </msbuild>

And this deploys our database project fine. You dont need the
afterdropbuild target - this is one way that project versions before
2008 gdr r2 had to be deployed.

There are a few things to watch out for.

The user that cc.net runs as must be a login on the target server and
have permissions to create and alter objects on in the target database

A lot of deployment options can be specified in the
DeploymentConfigFile file. We have a different one for different
enviroments. If you dont specify one, it will just use the one in the
project
You probably also dont need DefaultDataPath as well for the same reason

If you are using msbuild 4 you will need to change the msbuild version

Hope that helps

Anthony

On Mon, Jan 31, 2011 at 1:53 PM, Helmut <[email protected]> wrote:
> I know how to build and deploy my database project using MSBuild, but
> for some reason I can't get it translated into a CC build.  Here is
> the MSBuild execution:
>
> C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe /
> t:Build;Deploy /
> p:DeployToDatabase=true;BuildScriptName=EdAmericaDB.sql;outdir=C:\Work
> \SC\Database\edAmericaDB\sql\release
> \;TargetDatabase=EdamericaDB;TargetConnectionString="Data
> Source=devsql1\dev05;Integrated Security=True;Pooling=False" C:\Work\SC
> \Database\edAmericaDB\EdAmericaDB.dbproj
>
> CC just does not seem to like how I am splitting the MSBuild
> execution.  Here is the syntax that I am trying and it fails in the
> validator:
>
>        <msbuild>
>           <executable>C:\WINDOWS\Microsoft.NET\Framework
> \v4.0.30319\MSBuild.exe</executable>
>           <workingDirectory>c:\work\SC\Database\edAmericaDB</
> workingDirectory>
>           <buildArgs>/t:Build;Deploy /
> p:DeployToDatabase=true;BuildScriptName=EdAmericaDB.sql;outdir=C:\Work
> \SC\Database\edAmericaDB\sql\release
> \;TargetDatabase=EdamericaDB;TargetConnectionString="Data
> Source=devsql1\dev05;Integrated Security=True;Pooling=False" C:\Work\SC
> \Database\edAmericaDB\EdAmericaDB.dbproj</buildArgs>
>           <timeout>6000</timeout>
>           <logger>C:\Program Files\CruiseControl.NET\server
> \ThoughtWorks.CruiseControl.MsBuild.dll</logger>
>        </msbuild>
>     <msbuild>
>       <Target Name="AfterDropBuild">
>         <Message Text="Deploy of project database" />
>         <MSBuild Projects="C:\Work\SC\Database\edAmericaDB
> \EdAmericaDB.dbproj" Properties="OutDir=C:\Work\SC\Database\edAmericaDB
> \sql\release\;TargetDatabase=EdamericaDB;TargetConnectionString='Data
> Source=devsql1\dev05;Integrated
> Security=True;Pooling=False';DeployToDatabase=true;" />
>       </Target>
>     </msbuild>
>
> Any suggestions or help would be greatly appreciated.
>

Reply via email to