Thursday, March 05, 2009

Sharing libraries between Existing Projects and SSIS.

Hi all ! I have been playing with SSIS for the last few weeks. The package I was building was sophisticated and I had to reuse some of the code that I had in other .net library projects.

In SSIS Script Task, to reference an external library, you need to add the library to the GAC so it can find the binary at runtime. If you go that route, you will have to add a strong key to the existing library, right? will that's what I did, and it did not take me that long to figure out that created problems for me ! here is a simple example:

1- .net Projects 1 references Library Lib1, no strong keys, and dll of Lib1 is moved along with Project 1 when I do a complie.

2- SSIS needs to reference the library. So I add strong key to Lib1, recompile, and add to GAC.

3- now SSIS is happy.

4- Project 1 now does not have a copy of the DLL, visual studio automatically does not include Lib1 in Builds because you are not supposed to call it this way now, you need to move how you call Lib1 to the GAC way.

5- once Lib1 added to the GAK, and once you add a reference to the GAC assemply in the app.config, Project 1 will work again.

The question is, what if you do not have just one Project 1? what if you have 10 projects that reference Lib1, are you going to change all of them because of SSIS, hell no, I will not personally do that! ,,,

Easiest route is to find a way to directly use the code from Lib1 in SSIS script task, in my case Lib1 code was available so it was easy copy couple of .cs classes to the Script Task in the SSIS package, and Boom, I immediatly removed the reference to Lib1 from SSIS, and lived my life without strong keys / GAC stuff...

if you have a different way of doing it, let's know!!

No comments: