How to package database scripts into C# solutions and executable installers

For users that need to build deployment packages across environments from SQL scripts, either by using the C# solution or executable installer, ApexSQL Build offers an efficient way to accomplish this task in a few simple steps. This applies, for example, to situations where development changes to the structure and content of a production database need to be pushed as an upgrade.

The Consolidate scripts feature is easily accessible and it is located in the main window of ApexSQL Build. Besides other options, the user has the create C# solution with complete source code and Create executable file options available. A package creation process is basically the same for both output types with just a few different details in the last step.

In the following steps, C# solution will be used:

  1. Run ApexSQL Build
  2. Click the Consolidate button, under the Script section of the Home tab:
  3. Choose the C# solution, as the output type:

  4. The process continues with the Add SQL scripts step and addition of SQL script files and forming a deployment list, i.e. the package content. In some cases, the order of SQL script files is essential for the deployment, so they can be easily rearranged if necessary with the Up/Down commands:

  5. Once a package content is formed, additional Output options can be set up:

    The Optional information tab offers the possibility to create the package version and, in case of regular multiple update deployments, to keep track of changes and upgrades made in a chronological order:

So, what about the mentioned differences in the packaging process?

The process differs in a few details depending on the previously chosen option. In case of Packaging scripts into C# solution option, ApexSQL Build offers the selection of a Visual Studio version. If the Packaging scripts into executable installer option is selected, besides already described common settings, the user has an option to select to Run exactable on completion and to create Additional files as shown in the screen shot below:

Using the ApexSQL Build engine for creating and deploying C# solutions and executable installers is a simple process which can significantly speed up and make more reliable any kind of database schema upgrade processes.

March 12, 2015