Monday, April 14, 2008

Continous Integration and the Database

Spend some few days setting up a continous integration for a database project. Found some stuff on the internet but they got it all wrong :)

I am using Team Foundation Server 2008.

The only thing you need to do is modify the TFSBuild.proj

Modify the following sections. This enabled the automatic generation of a sql script that will be copied in the Drop Folder.
Find the SoltionToBuild tag and add the properties as shown below:

<SolutionToBuild Include="$(BuildProjectFolderPath)/../../CIDB/CIDB.sln">

Add the default configuration to the ConfigurationToBuild ItemGroup as shown below (make sure to match it to your settings in the Configuration Manager)
The list of configurations to build. To add/delete configurations, edit this value. For example,
to add a new configuration, add the following lines:

<ConfigurationToBuild Include="Debugx86">

The Include attribute value should be unique for each ConfigurationToBuild node.
<ConfigurationToBuild Include="ReleaseAny CPU">
<PlatformToBuild>Any CPU</PlatformToBuild>

<!--Include the configuration to build this generates a .sql file in the drop folder-->
<ConfigurationToBuild Include="DefaultAnyCPU">
<PlatformToBuild>Any CPU</PlatformToBuild>

Next add the following section to the end of the TFSBuild.proj file. the %3B is the escape character for ';' in MSBuild


<TargetConnection>Data Source=.%3BIntegrated Security=True%3BPooling=False</TargetConnection>

<Target Name="AfterDropBuild">
<MSBuild Projects="$(SolutionRoot)\CIDB\CIDB\CIDB.dbproj"

Targets="ReBuild;Deploy" /> <!—Need to specify the Rebuild target otherwise fails -->


If you modify your source folder setting in the workspace - defaults to $(SourceDir)- make sure that you override your SolutionRoot property

by adding the following



<SolutionRoot>C:\Workspace_Build02 </SolutionRoot>


Thats all there is to it :)

Coming up automatically generate an upgrade script to deploy to production systems... I installed the Database Team Edition on the build agent but I am not quite sure if its necessary I will investigate this... I dont know if its default part of ms build