Click here to Skip to main content
15,884,589 members
Articles / Database Development / SQL Server / SQL Server 2008

Continuous Integration for Databases with Visual Studio

Rate me:
Please Sign up or sign in to vote.
4.85/5 (14 votes)
23 Nov 2010Apache18 min read 63K   1.2K   68  
Provides a framework for predictably compiling, extracting, and deploying a database project.
<?xml version="1.0" encoding="utf-8"?>
<ScriptExecutorConfiguration>
  <!--
    The ScriptExecutorConfiguration file is simply a serialized SqlDeployment.ScriptExecutorConfiguration class.
    This contains a serializable dictionary that represents the script execution sequence for the deployment utility (SqlDeployment.ScriptExecutor),
    which is currently called by the MSBuild task DeployDatabase, as well as the production deployment utility SqlDeployment.DatabaseDeployment

    This is used to be provide a more granular level of control over the database deployment process. Custom scripts can be inserted
    in the execution sequence. For example, the custom (not generated) script AlterTables.sql handles upgrading tables between database
    versions. This has been manually added to the exection sequence script to run directly after the Tables.sql file, which creates
    tables that are missing.

    Features to add in the future would be the addition of a build version after the msbuild process completes, and putting logic
    in the custom scripts to interrogate database versions before execution (or data migration).
  -->
  <ExecutionSequence>

    <Item>
      <Key>
        <!--
          The sequence number. The order in the config file doesn't actually matter, since this is sorted by the key value at run time.
          it is, however, important that the key is UNIQUE, since it is the key of a dictionary object.
        -->
        <int>3</int>
      </Key>
      <Value>
        <!--
          The name (and relative path) of the script to execute. This is relative to the calling application, so in the case of
          the DatabaseDeployment utility it is relative to the application folder, whereas when called from MSBuild it should
          be relative to the project root.
        -->
        <string>Output\DropConstraints.txt</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>1</int>
      </Key>
      <Value>
        <string>Output\Filegroups.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>2</int>
      </Key>
      <Value>
        <string>Output\FullTextCatalogs.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>4</int>
      </Key>
      <Value>
        <string>Output\DropRedundantObjects.txt</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>114</int>
      </Key>
      <Value>
        <string>Output\ManipulateDataPostApply.txt</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>10</int>
      </Key>
      <Value>
        <string>Output\DropFunctions.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>20</int>
      </Key>
      <Value>
        <string>Output\DropViews.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>25</int>
      </Key>
      <Value>
        <string>Output\Roles.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>30</int>
      </Key>
      <Value>
        <string>Output\Schemas.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>40</int>
      </Key>
      <Value>
        <string>Output\Tables.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>45</int>
      </Key>
      <Value>
        <string>Output\AlterTables.txt</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>50</int>
      </Key>
      <Value>
        <string>Output\Routes.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>55</int>
      </Key>
      <Value>
        <string>Output\Messages.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>60</int>
      </Key>
      <Value>
        <string>Output\Contracts.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>65</int>
      </Key>
      <Value>
        <string>Output\Queues.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>70</int>
      </Key>
      <Value>
        <string>Output\Services.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>75</int>
      </Key>
      <Value>
        <string>Output\Functions.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>80</int>
      </Key>
      <Value>
        <string>Output\Views.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>85</int>
      </Key>
      <Value>
        <string>Output\Triggers.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>90</int>
      </Key>
      <Value>
        <string>Output\CircularReferences.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>95</int>
      </Key>
      <Value>
        <string>Output\ClusteredConstraints.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>100</int>
      </Key>
      <Value>
        <string>Output\Constraints.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>105</int>
      </Key>
      <Value>
        <string>Output\FullTextIndexes.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>110</int>
      </Key>
      <Value>
        <string>Output\Procedures.sql</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>115</int>
      </Key>
      <Value>
        <string>Output\LoadReferenceData.txt</string>
      </Value>
    </Item>
    <Item>
      <Key>
        <int>120</int>
      </Key>
      <Value>
        <string>Output\RolePermissions.txt</string>
      </Value>
    </Item>
  </ExecutionSequence>
  <!--
    The name of the target database. This allows you to specify a database name on a server, and restrict the script execution
    from running against any other database.
  -->
  <TargetDatabase>$safeprojectname$</TargetDatabase>
  <!--
    The name of the target server. This allows you to specify a server, and restrict the script execution
    from running against any other server. NOTE: .\SQLExpress would not be valid, since the actual server name would be resolved
    as MACHINENAME\SQLExpress. the .\ prefix is a shortcut, and the comparison would be on MACHINENAME\SQLExpress != .\SQLExpress,
    which would fail.
  -->
  <TargetServer></TargetServer>
</ScriptExecutorConfiguration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Chief Technology Officer
Australia Australia
Emigrated to Sydney, Australia in 2013 from Cape Town, South Africa, and have been writing commercial software since 1997.

Expertise includes MS SQL Server (7 till latest), C#, VB6, VB.NET, VBScript, JavaScript, ASP, HTML, WPF Angular, Windows Installer and InstallShield (multiple versions) and a partridge in a pear tree. MSBuild, CruiseControl.NET, TFS, Jenkins, TeamCity, ant and nant are all necessary sidelines. Have tinkered with Java and C++

Experienced with Enterprise level application design and deployment, as well as sizing and scaling high volume OLTP database designs up to tens of thousands of transactions per second and diagnosing application and database performance bottlenecks.

Comments and Discussions