Create and use a C# Assembly for SSIS - Page 2
|Create and use a C# Assembly for SSIS|
Sign, Build and Deploy
Create a GAC signature
Skip this step if you already have a project-wide GAC signature file available with which to sign your assebly with.
Open your console and create a signature file using the sn (StrongName) command, which is installed with the .Net SDK:
- C:>sn -k Keyfile.snk
- Microsoft (R) .NET Framework Strong Name Utility Version 2.0.50727.42
- Copyright (c) Microsoft Corporation. All rights reserved.
- Key pair written to Keyfile.snk
Add the signature file to your project
Add your signature file to your project just like any other existing file:
Sign your assembly
In addition to adding the file to your project, you also need to specify that you would like to sign your project. This is done from the Project Properties screen. Select the "Signing" tab, choose to "Sign the assemby" and select your signature file from the dropdown box.
Configure the deployment
At this stage, your assembly is ready to build, but it will not be recognized by SSIS until it is properly deployed in the GAC.
In summary, the deployment consists of 3 steps:
Signing the assembly (done that above)
Copy the physical .dll file to the target machine's .NET framework directory
Install the assemply to the GAC
The best place to do the last two steps is to script them in the project's Pre- and Post-build event handlers.
Click on the "Build Events" tab and enter the following code for the Pre-build event. The .NET framework directory for Visual Studio 2005 is C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727, for Visual Studio 2008 it is C:\Windows\Microsoft.NET\Framework\v3.5. These are the only directories that SSIS can reference. Bare this in mind for the code below.
- : Uninstall the previous assembly from the GAC
- "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /u $(TargetName)
Enter this for the Post-build event:
- : Install the assembly to the GAC
- "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /i "$(TargetPath)"
- : Copy to directory where SSIS can read it
- copy "$(TargetPath)" "C:WINDOWSMicrosoft.NETFrameworkv2.0.50727" /y
I specify the fully-qualfied path for gacutil.exe here since it is not by default on your path. Ideally though, C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin (or wherever gacutil.exe lives, depending on your version of Visual Studio or Microsoft SDK) should be on your path.
Build and deploy the Assembly!
Press Shift-Ctrl-B. (Learn to use keyboard shortcuts in Visual Studio!)
|< Prev||Next >|