I decided to do a VSAE series that explains how to use the Visual Studio Authoring Extensions to extend and customize Service Manager. This is indeed an excellent extension when Visual Studio is your Service Manager authoring tool! If it’s not, it’s definitely worth looking at it, and the System Center VSAE help you being successful.
Part 1 – VSAE Part 1: Creating a new CI Class (this post)
Part 2 – VSAE Part 2: Creating a Folder with a custom Image
Part 3 – VSAE Part 3: Creating Views by using Snippet Templates
Step 1 – Preparation
First you need to install Visual Studio 2010. After that, download and install the Visual Studio Authoring Extensions from here. Now start Visual Studio and create a new Project. Select “Service Manager 2012 Management Pack”, select name and location for the project and the solution.
When the project is created, it contains two references. These will be used in the “Manifest” area of the Management Pack to reference to other Management Packs.
Step 2 – Create a new Class
Now let’s add a class to our Management Pack project. You can do this by adding a new item. Select the Class template and define a meaningful name.
A new file is added to the project which holds the class definition. The cool thing when using VSAE is, that the MP elements are stored in different MP fragment files. Compared to one big XML file, this makes it more transparent and elements can be found and edited much faster. At the end when the MP is built, everything is glued together into a single XML-, MP- or MPB-file.
When you double click on the new item it opens and can be edited. The template contains a class example that helps creating your very own class. Also, IntelliSense is available to simplify the authoring process.
In this example I will create a new class called “Car” which will later be used to store information and relationships about car CIs in the CMDB. That means that some things need to be changed from the example class. Because I want to add another CI class, I need to derive from the Configuration Item class System.ConfigItem. Because this class lives in another Management Pack, we need to reference to this class to get the base class. This is one of the default references that is already there. The alias is predefined and is called System.
Now back to the class where I change these things:
- Change the base class to System!System.ConfigItem
- Change the Accessibility to Public to make sure I can access the class from outside this Management Pack
- Add some properties to the class, one as the key property which automatically increments
- Add the needed display strings to the language pack area to translate the IDs to meaningful names
Step 3 – Deploy the Management Pack
Now as the class is ready it’s time to deploy the Management Pack to the Service Manager Management Group. This can be done directly from Visual Studio. Configure the properties of the project.
First define the Management Pack ID, Version and Friendly Name.
If needed, the Management Pack can be automatically sealed before it is deployed to the Management Group. This makes sense if the MP holds type definition. In this example, I choose to seal the MP, define the path to the strong name key file which is needed for the sealing process. You can get more information about that here. As a last step, I change the Configuration and Platform options as shown in the Screenshot.
Next I need to select the Management Server to connect to for the automatic deployment process. Just add a Management Server and specify the credentials.
The last configuration is about incrementing the MP version and the deployment process.
Now we are ready to go. First, save all the files of the project, then build the solution by hitting F6 or using “Build Solution” from the “Build” menu. This will create your Management Pack from the different fragments and store it in the bin\release folder within your project folder. There are several files created: a XML file (unsealed), if the option was selected a MP file (sealed) and a MP bundle file (MPB, to bundle additional resources with the Management Pack).
Now, to deploy the MP bundle to the Management Group you need to start the debugging process in Visual studio. If you specified to use different credentials to connect to the Management Group, you are prompted for those.
Step 4 – Verification
When the deployment process was successful, you should be able to see the new MP in the Management Pack list.
Because I only created a class in this example, we are not able to see anything for now. But you could now start creating views and use the created class to display and create car CIs. Something like this.
In the next part of this series I will demonstrate how to handle Folders, Views and Images in Visual Studio with VSAE. Make sure you don’t miss it!