© Andy Leonard 2021
A. LeonardBuilding Custom Tasks for SQL Server Integration Serviceshttps://doi.org/10.1007/978-1-4842-6482-9_3

3. Creating the Assembly Project

Andy Leonard1  
(1)
Farmville, VA, USA
 

If you followed the previous chapter and set up Azure DevOps or some other source control for your project, good! If not, you may add the assembly we build in this section to source control later, but if you plan to use Git, you may regret skipping the previous chapter.

Creating a custom SSIS task begins with creating a .Net assembly. We engage in practices that differ from many .Net development projects because we are creating a control that will be used in other Visual Studio projects, specifically, SSIS projects.

In this chapter, we take steps to establish the foundation of our project while considering the following steps. The very first step is how we open the Visual Studio IDE. If Visual Studio is open, please close it before continuing.

Opening Visual Studio IDE

I can hear you thinking, “Hold on a minute, Andy. Do you propose to start by telling us how to open Visual Studio?” Yes. Yes, I do. “Why?” I’m glad you asked. If you are new to .Net development and seeking answers to questions about developing a custom SSIS task (or similar code), this is one of the tricky things that real software developers do not remember to tell you. They are not intentionally leaving stuff out to trip you up, nor are they bad people; they simply do not remember making changes to their development environments to support this kind of development.

When you open Visual Studio, right-click Visual Studio in the Windows Start menu, hover over “More,” and then click “Run as Administrator” as shown in Figure 3-1:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig1_HTML.jpg
Figure 3-1

Run Visual Studio as Administrator

You do not have to take this step. But taking this step will save you time and effort later. Why? Later we will configure Build operations to copy output files to the Global Assembly Cache (GAC), which will require elevated permissions.

When you click Run Visual Studio as Administrator, you will be prompted to confirm that you wish to run Visual Studio as shown in Figure 3-2:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig2_HTML.jpg
Figure 3-2

Confirm you really want to run Visual Studio as administrator

Once the Visual Studio startup screen displays , click the “Create a new project” tile to begin a new project as shown in Figure 3-3:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig3_HTML.jpg
Figure 3-3

Start a new project

When the “Create a new project” window displays, search for, and then select, a C# Class Library (.Net Framework) project type, or in the .Net language of your choosing. I chose C# for the language and named the project ExecuteCatalogPackageTask as shown in Figure 3-4:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig4_HTML.jpg
Figure 3-4

Selecting a project type

Select “Class Library (.NET Framework)” and click the Next button.

When the “Configure your new project” window displays, enter a name for the project and set the project files location as shown in Figure 3-5:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig5_HTML.jpg
Figure 3-5

Configuring and naming the new project

Name the project ExecuteCatalogPackageTask.

Store the project in the path created when the Azure DevOps Git repo was cloned.

Click the Create button to create the project.

Please note the ExecuteCatalogPackageTask folder is now present in the gitReposBook Code folder as shown in Figure 3-6:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig6_HTML.jpg
Figure 3-6

The new Visual Studio project in the local repo

The next step is renaming the default class that was created as Class1 in the Visual Studio project. In Solution Explorer, click on the Class1.cs class twice (slowly), and Class1 will enter rename-edit mode. Change the name to ExecuteCatalogPackageTask as shown in Figure 3-7:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig7_HTML.jpg
Figure 3-7

Renaming Class1 to ExecuteCatalogPackageTask

When you hit the Enter key, you will be prompted to change all references to Class1 to ExecuteCatalogPackageTask. Click the Yes button as shown in Figure 3-8:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig8_HTML.jpg
Figure 3-8

Renaming all references

These are the first steps to creating a custom SSIS task using Visual Studio 2019. Experienced developers will likely find this information trivial – this book is not written for experienced developers.

A key takeaway from this section: Remember to start Visual Studio as an Administrator.

Adding a Reference

The .Net Framework was invented so developers could get a few hours of sleep. It encapsulates a host of common functions which developers may use in applications. That’s pretty cool, but even cooler is the fact that many platforms and applications expose functionality via .Net assemblies. Coolest of all (for our purposes), SSIS assemblies allow us to create custom tasks!

We must first reference these .Net Framework assemblies. To reference an assembly, open the ExecuteCatalogPackageTask Visual Studio solution if it is not already open. In Solution Explorer, click the ExecuteCatalogPackageTask project in Solution Explorer, and then expand the References virtual folder as shown in Figure 3-9:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig9_HTML.jpg
Figure 3-9

Project References in Solution Explorer

Let’s add a reference to an SSIS assembly. Right-click the References virtual folder, and then click Add Reference as shown in Figure 3-10:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig10_HTML.jpg
Figure 3-10

Preparing to add a reference

This opens the Reference Manager window. Expand the Assemblies item in the Reference Types list on the left. Click the Extensions item in the Assemblies list. Scroll until you find the Microsoft.SqlServer.ManagedDTS assembly, and select its checkbox as shown in Figure 3-11:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig11_HTML.jpg
Figure 3-11

Adding the Microsoft.SqlServer.ManagedDTS Assembly Reference from AssembliesExtensions

If the assembly is not located in the AssembliesExtensions list, you will have to browse for the Microsoft.SqlServer.ManagedDTS assembly. On my virtual machine, I located the file in the following folder:

C:WindowsMicrosoft.NETassemblyGAC_MSILMicrosoft.SqlServer.ManagedDTSv4.0_15.0.0.0__89845dcd8080cc91

Add a reference to the Microsoft.SqlServer.ManagedDTS assembly as shown in Figure 3-12:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig12_HTML.jpg
Figure 3-12

Adding the Microsoft.SqlServer.ManagedDTS Assembly Reference from the file system

When you click the OK button, the References virtual folder appears as shown in Figure 3-13:
../images/449652_2_En_3_Chapter/449652_2_En_3_Fig13_HTML.jpg
Figure 3-13

Reference successfully added

Conclusion

At this point in development, we have
  • Created and configured an Azure DevOps project

  • Connected Visual Studio to the Azure DevOps project

  • Cloned the Azure DevOps Git repo locally

  • Created a Visual Studio project

  • Added a reference to the Visual Studio project

It’s time to check in our code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.234.62