In the Life of a TFS Configuration Manager Part 4: Building Deploy Scripts for Database projects (.dbproj) with TFS

This was not supposed to be a problem. In Visual Studio, you can easily generate a database deployment script by setting project properties on the Deploy tab.


However, when using TFS/MSBuild automated build, this did not work – no .sql file was generated. I found a clue in the documentation, An Overview of Database Build and Deployment. There is an example to deploy a database:

MSBuild /target:Deploy /p:UseSandboxSettings=false /p:TargetDatabase=UpdatedTargetDatabase;TargetConnectionString="Data Source=(local)\SQLEXPRESS;Integrated Security=True;Pooling=False" MyProjectName.dbproj

The important parameter here is the first one, /target:Deploy. Specifying it on the command line is fine if you’re just building this project, but what if it is part of a larger solution? Turns out to be relatively easy. Just edit the project file and add Deploy as a default target:

<Project DefaultTargets="Build;Deploy" xmlns="" ToolsVersion="4.0">

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s