When you want to build and deploy database projects with team build you need to edit the database project file and the Team Build file. That’s because database projects store any non-default values for the TargetDatabase, TargetConnectionString, and DefaultDataPath properties in a <ProjectName>.dbproj.user file. *.user files are not checked into version control in order to let every user use different values.
Step 1 – Modify build project file (team build .proj file)
Open the BuildDefinition.proj file, and at the bottom of the file, between the </ItemGroup> element and the </Project> element, add the following:
<Target Name="AfterDropBuild"> <MSBuild Projects="$(SolutionRoot)\SolutionName\ProjectName\ProjectName.dbproj" Properties="Configuration=Default;OutDir=$(SolutionRoot)\..\binaries\Default\" Targets="Deploy" /></Target>
Step 2 – modify the database project file
The target connection and database are stored in the ProjectName.dbproj.user file, which is user specific and not typically checked in to version control. You require those settings to deploy your database. Therefore, you must modify the ProjectName.dbproj file manually to specify the target connection and database.
Copy the lines that contain the definitions for the TargetDatabase and TargetConnectionString properties from the section in the ProjectName.dbproj.user file for the configuration that you want to build. These lines will resemble the following:
<TargetDatabase>MyTargetDatabaseName</TargetDatabase><TargetConnectionString>Data Source=ServerName\InstanceName;Integrated Security=True;Pooling=False</TargetConnectionString>
If TargetDatabase and TargetConnectionString already contain empty elements, you should overwrite those entries.
More into at the msdn page.
Similar Posts:
- Automatically Compare Data and Schema Using MSBuild and Data Dude
- Data Dude:Deploy Action On CTP16 Does Not Deploy The Database To Target
- Create custom task for MSBuild – Step by Step
- How To: Build Non-MSBuild Projects with MSBuild
- Custom Build Number In Team Build
Tags: Team Build, Team Build 2008, Team System 2008, Team System 2010, VSTS DB Pro
About


This comment originally written by:
When you want to build and deploy database projects with team build you need to edit the database project file and the Team Build file. That's because database projects store any non-default values for the TargetDatabase, TargetConnectionString, and
This comment originally written by:Team System News
MRod on External Team Foundation Server Tools. Brian Harry on Team Foundation Server 2008 SP1 Preview….