Posts in this series:
- Creating a Custom SSIS 2012 Task – The Rambling Introduction
- Creating a Custom Task in SSIS 2012 – Getting Started
- Creating a Custom Task in SSIS 2012 – Configuring the Project
Preparing to Add a Key
I recommend opening a command window as an Administrator to begin. As before, right-click the Developer Command Window tile and then click the Run as Administrator item below:
Figure 1: Opening an Administrator Command Window
When open, the Administrator command window appears as shown in Figure 2:

Figure 2: Administrator Command Window
We are creating an assembly (actually, a couple assemblies) that will reside in the Global Assembly Cache, or GAC. In order to live in the GAC, assemblies must be signed. We sign assemblies using strong name key files. At this point in our project configuration, we need to generate a key suitable to sign our assemblies. The good news: Microsoft provides a Strong Name utility for creating keys. The bad news: It moves around with new releases of the .Net Framework.
If you are developing on Windows 8, you can find the strong name utility in the ”C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\” folder. It is named “sn.exe” so the full path is ”C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe”. If the Mayans are wrong and you are reading the post in the distant future and snickering about how archaic Windows 8 was, search for “sn.exe” and use the latest version you find.
Now, you can do this however you like but I am going to recommend you start a text file to preserve these command lines for future use. I firmly believe you will thank me later.
I open Notepad and paste the following lines:
– key generation
“C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe” -k key.snk
“C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe” -p key.snk public.out
“C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe” -t public.out
The first line creates the public/private key pair and puts them in a file named key.snk.
The second line extracts the public part of the key pair to a file named public.out.
The third line reads the public key from the public.out file.
If you have followed my advice, you have a Visual Studio solution, a command window, and Notepad open. Save the Notepad file as MyFirstTaskNotes.txt and remember where you save it. Return to Visual Studio. In Solution Explorer right-click the MyFirstTask project, hover over Add, then click Existing Item as shown in Figure 3:
Figure 3: Adding an Existing Item to the MyFirstTask Project
Navigate to the location of your MyFirstTaskNotes.txt file, select it, then click the Add button:

Figure 4: Find the MyFirstTaskNotes.txt File
MyFirstTaskNotes.txt now appears in Solution Explorer:

Figure 5: MyFirstTaskNotes.txt in the Solution
MyFirstTaskNotes.txt has also been added to your project folder:

Figure 6: MyFirstTaskNotes.txt in the Project Folder
Now that you have a copy of the file included with your project, delete the original from the location where you originally stored it:
Figure 7: Deleting the Original MyFirstTaskNotes.txt
Why? Visual Studio made a copy of your file when it added it to your solution. We want to continue to work with that copy, not the one we made before adding it to the project.
Now would be an excellent time to take advantage of some free source control functionality available at TFS.VisualStudio.com.
There are two types of software developers: Those who use source control and those who will. The first time you lose a few hours of awesome-break-through coding, you will. I promise. If you use a source control product to maintain your solution, the file you just added is part of that solution. That’s why we added it to the project.
Creating the Key
In the command window, navigate to the MyFirstTask project directory. The project directory will contain MyFirstproject.vb, MyFirstProject.vbproj, and MyFirstprojectNotes.txt as shown in Figure 8:
Figure 8: Navigating to the MyFirstProject Project Directory
If it is not already open, open the MyFirstTaskNotes.txt in Visual Studio from Solution Explorer. Select the first line, copy it, and paste it into the command window (right-click and select Paste) as shown in Figure 9:
Figure 9: Pasting into the Command Window
The sn.exe command is pasted into the command window:
Press the Enter key to execute the sn.exe command, creating the key file in the MyFirstTask project directory:
Figure 11: Key.snk File Created!
Next we need to get the public key from key.snk’s public/private pair. First, we extract the public key to a file named public.out using the second line stored in MyForstTaskNotes.txt:

Figure 12: Public Key Extraction
Finally, we need to read the public key value out of the file to which we extracted it:

Figure 13: Reading the Public Key
Right-click inside the command window and click Mark:
Figure 14: Preparing to Mark Before Copying to Clipboard
Using the left mouse button, highlight the public key value:

Figure 15: Selecting the Public Key in the Command Window
Right-click the highlighted text. Note that no context menu will appear. Your indication the text has been copied to the clipboard is the highlighting and “Select” text in the title bar disappear:

Figure 16: Text Selected to the Clipboard
Store the public key in a comment inside the class MyFirstTask.vb in Visual Studio. We will use it here later:
Signing the Assembly (Finally!)
In Solution Explorer, open MyProject as shown in Figure 18:
Once MyProject opens, navigate to the Signing page. Check the “Sign the assembly” checkbox. Click the “Choose a strong name key file” dropdown and select “<Browse…>” as shown in Figure 19:

Figure 19: Signing the Assembly
Browse to the key.snk file in the MyFirstTask project folder:

Figure 20: Navigating to the Key.snk File
Click the Open button to use the key.snk file to sign the assembly:
Click the Save All button (or File-> Save All) to save your Visual Studio solution. If you are using source control, this is an excellent place to save your file to Source Control.
You can get a copy of the Visual Studio solution in this state here.
:{>












Pingback: Creating a Custom SSIS 2012 Task – Binding the Task and Editor - Linchpin People, LLC