Saturday, 26 October 2013

Custom Task in BIML Script

I want to add a custom task to my BIML Script. How do you do that in BIML?


1) Intro
For BIML you first need to install BIDS Helper. At the time of writing the current version of BIDS Helper is 1.6.4. For this example I assume you have basic experience with writing BIML Script and you have installed the Custom Task you want to use in the BIML Script.

2) Create example package
Create an example package with the Custom Task. You need to copy some of the XML code later on. For this example I will use my own custom ZipTask. Two string variables are used for storing the filepath of the sourcefile (that will be zipped) and filepath of the zipfile.
Custom Task with to variables

3) BIML Script Variables
The ZipTask uses two variables and it stores the GUID of those variables in its properties. When I create the variables in the BIML Script I use the same GUID's as in my example package. To get those GUID's click on the variable and go to its properties. Or look it up in the xml code of the example package by right clicking the package in the solution explorer and choose View Code.
BIML Script with two variables with GUID's

4) BIML Script CustomTask
The BIML Script for a custom task is:

You can lookup the value of the CustomTask properties in the XML code of your example package. Search for the DTS:CreationName and DTS:TaskContact properties of your Custom Task. Then copy and paste the exact value to the corresponding property in the BIML Script.
Lookup property values in xml code example package

5) ObjectData
Now we need to fill the ObjectData tag. Go back to the XML code of your example package and search for the ObjectData tag of your custom task. Copy the contents (everything between <DTS:ObjectData and </DTS:ObjectData>) to an advanced text editor like Notepad++ where you can replace the following codes
<    by   &lt;
>    by   &gt;
\r\n by               (Carriage Return + Line Feed by a Space)

Now copy all that code from your text editor to the ObjectData tag within your BIML Script. This text contains all the properties of the custom task including the guid of the two variables.

6) Finish
Now you're ready to generate the package with your custom task.
The Result

No comments:

Post a Comment

Please use the SSIS MSDN forum for general SSIS questions that are not about this post. I'm a regular reader of that forum and will gladly answer those questions over there.

All comments are moderated manually to prevent spam.

Related Posts Plugin for WordPress, Blogger...