3
votes

In Visual Studio 2010 there is a nice feature of the database project that allows you to deploy to a database as well as set up various environments based on your configuration (Build deploy etc)

I Would like to integrate this into our automated build environment.

Firstly by having the deploy script run after a successful build on my local machine. (So I can go straight into running the unit tests)

Then by Having the deploy script run after the successful build on our build server. so that any schema changes required for the unit and integration tests will run.

How can I adjust the MSBuild or similar to run these in deploy mode.

1

1 Answers

4
votes

Use the MSBuild task to call the "dbproj" file. Pass "DBDeploy" as the target and the build configuration as a property, e.g.:

<MSBuild Projects="MyDb.dbproj" 
         Targets="DBDeploy" 
         Properties="Configuration=$(Configuration)" />

On a build server, you might also need to supply properties like TargetConnectionString and TargetDatabase.