I've been developing some [BlackfishSQL] stored procedures. Since they are written using Delphi, the typical cycle of events is
- Develop stored procedure
- Compile package
- Shutdown the [BlackfishSQL] server
- Copy the assembly to the deploy location
- Restart the [BlackfishSQL] server
Its the same basic steps over and over, so I figured it was a good opportunity for a bit of automation. So I've developed an MSBuild task that is callable from the IDE. In the screen shot below can be seen a menu option named "deploy".
Having compiled the package containing the stored procedures, I can now select the deploy menu option.
The following actions are performed automatically for me
- Stop the [BlackfishSQL] Server
- Copy the assembly
- Restart the server.
So how did I do this ?
Starting off in my stored procedure package, the first thing I did was add a "MSBuild Targets File". This item resides in the "New Item Dialog". This can be seen in the screen shot below.
The finished targets file can be seen in the next screen shot
Basically I developed three custom tasks in a Dephi package, referenced in the Targets file with the UsingTask xml element. I then used these references in the Target XML element. Each Target element becomes a menu option in the project manager. This can be seen in the very first screenshot.
So what does a custom task look like ?
In the Microsoft.Build.Utilities assembly located in the framework directory is a namespace Microsoft.Build.Utilities. Inside that namespace is a class called Task.
This class serves as a base class for your own custom tasks. For example this is the definition for my custom task TStopBlackfishSQLServiceTask.
And this is the implementation
function TStopBlackfishSQLServiceTask.Execute: boolean;
This task basically stops the Blackfish server service.
I've packaged up the complete custom task project with an example targets file included.
Once you download and have compiled you should be ready to go. The first step is to open MyTarget.Targets and modify as needed. Your most likely going to have to change the directory references to where the custom build task assembly is located and also where the stored procedure package is located.
Its assumed that you already have a project with stored procedures ready to go.
If you take another look in the targets file I have supplied you will see this
This is where I define what files I would like the copied.
<TFileCopyRetry FilesToCopy="@(FileToDeploy)" DestinationFolder="c:\develop\h2\blackfishsp" />
and the above completes the definition and indicates to copy the fies to c:\develop\h2\blackfishsp
As a side note, I modified the Blackfish server service config file to load packages from this directory. The config file is BSQLServer.exe.config in the Rad Studio bin directory.
For me the bottom of this file looks like
<add key="blackfishsql.assemblyPath" value="c:\develop\h2\blackfishsp" />
The full source code can be downloaded from CodeCentral at this location.
Any feedback is welcome.