Visual Studio Authoring Extensions - Basic Operations
Installation
To use the Visual Studio Authoring Extensions, you must have a copy of Visual Studio installed. Obtain the installer, which will be made publically available soon. Double-click the .msi to start the installation process. No configuration is necessary.
Creating a New Management Pack
To create a new management pack, you first have to create a new management pack project. A project is the Visual Studio term for the collection of code that will be compiled into a finished form – often an executable, but in this case, a management pack. From the Visual Studio Start Page, select the New Project… link, or click File → New → Project. The New Project dialog box appears.
Select Management Pack in the Installed Templates pane on the left. Three options appear in the middle pane:
- Operations Manager 2012 Add-On Management Pack
- Operations Manager Core Monitoring Management Pack
- Service Manager 2012 Management Pack
Use the Add-On Management Pack if you have an existing Operations Manager 2007 management pack that you want to update to the Operations Manager 2012 schema. The primary reason to do that is to add dashboard items to an older management pack, because dashboards will only work under the 2012 schema. For all other management packs, and for creating a new management pack from scratch, select the Operations Manager Core Monitoring Management Pack.
The Service Manager Management Pack project is used for System Center Service Manager 2012, and is not discussed in this documentation.
At the bottom of that dialog box there are three fields. The first is the name of the management pack. The second field is the location where the MP will be stored. This can be anywhere, because deploying the MP is a separate process. The default is c:\Users\username>\documents\Visual Studio 2010\Projects. The Solution name field is the same as the MP name by default. You’ll almost always leave the “Create directory for solution” box checked. Click OK when you’re done.
The Visual Studio interface
Visual Studio opens the new management pack. The main pane will be empty at first, but there’s a couple of things to notice in the interface right now. On the right, by default, are two open windows.
The top window is the Solution Explorer, and that’s where you’ll find the elements that make up your management pack as you create them. Visual Studio groups files into solutions, and when you created the new management pack, a new solution was created for you. Within the solution is a project, currently named for your management pack. If you want to create more than one management pack for your application, for example, a monitoring MP and a library MP, you would create multiple projects within the same solution. To create a new project, right-click on the solution at the top of the window and select Add → New Project.
The Solution Explorer is where you add new management pack elements. To add an element, right-click on the solution item and select Add → New Item (this is discussed in more detail later). After you add new items, they are displayed in the Solution Explorer. A folder named References is already present, with a handful of references inside. These are the references that are created by default with a new management pack. You can also add new references here; right-click the References folder and select Add Reference. A dialog box appears allowing you to select the management pack you want to reference.
Underneath the Solution Explorer is the Properties window. The contents of the properties window reflect the properties of whatever item is selected in the Solution Explorer. You can edit the properties of that item directly in the Properties window. For most items, you won’t need to edit the properties, but for the Advanced Template items, the Properties window is the primary way to set the properties, which are then created in XML for you. The properties for Advanced Template items are discussed in more detail in the [[Visual Studio Authoring Extensions - Advanced Templates|Advanced Templates]] section.
Management Pack Fragments
The first important thing to understand about creating management packs in VSAE is that although the completed MP is an XML file, you won’t see a single, monolithic XML file in the project. Instead, you’ll see a series of .mpx files. Each .mpx file contains a fragment of XML, and when you build the project, these fragments will be unified into a single management pack file, either .xml or .mp. Each fragment can contain as much or as little of the management pack as you want, but each template is intended to create a single type of management pack element in a separate file.
Adding MP Elements
Right-click the project in Solution Explorer, and select Add → New Item. (You can also use the Add New Item button on the toolbar, or press Ctrl+Shift+A.) The Add New Item dialog box opens, and you’ll see a list of the various items that you can add to your MP. These are divided into five categories:
Category |
Usage |
Code |
Contains two items: Empty Management Pack Fragment and Empty Management Pack Template group. These are used to create elements that do not yet have item templates provided, such as custom data sources. |
Resources |
Contains resources that other MP elements can use. At this time, there are templates for Jscript, PowerShell, and VBscript script files, and an item for bitmap files. |
Samples |
This category is currently empty. |
Templates |
The items in this category are advanced templates, and create a management pack template group when selected. As discussed in the [[Visual Studio Authoring Extensions - Advanced Templates|Advanced Templates]] article, a management pack template group provides an interface for setting the properties of a template item, without having to access the XML directly. |
XML |
The items in this category are simple templates. When you select one of these, an XML editor opens, and an XML skeleton is provided to help you configure the item. For simple templates, you edit the XML directly. The various simple templates are discussed in the [[Visual Studio Authoring Extensions - Simple Templates|Simple Templates]] document |
The Online Templates category is currently not used, but will be used in the future to provide additional samples.
At the bottom of the Add New Item window, provide a name for the new element, and click OK. The management pack fragment now appears in the hierarchy in the Solution Explorer.
Setting Management Pack Properties
Select Project → <Management Pack Name> Properties. The Properties window for this MP appears.
On the Management Pack tab, you can change the ID of the management pack, and the current version number. Keeping the version number current is important; see Version Control. The Management Pack Friendly Name is the name that displays in the Operations Console for this MP. You can also change the default namespace for the management pack. If you change this, the prefixes in the management pack elements will change when you build the project.
On the Build tab, you can select the configuration and platform for which these properties apply. By default, the configuration is the active configuration and the platform is the currently active platform. These settings are more commonly used with other types of Visual Studio projects. In this case, they primarily affect the folder where the generated MP will be found.
Below those settings, there’s a single active checkbox initially: Generate sealed and signed management pack. If you build the project without checking this box, you’ll generate an unsealed management pack, with a .xml extension. Although sealing management packs is recommended, it is not required, especially during development and testing. For more information about sealed and unsealed management packs, see Managment Pack Formats.
If you select to generate a sealed and signed management pack, a new set of options becomes available:
- Delay signing: For security reasons, some organizations have a delayed process for signing assemblies. Using this process, you sign the assembly with only the public key and then complete the signing with the private key just prior to shipping. This allows access to the private key to be limited to only a few individuals. Using this checkbox allows you to partially seal the management pack for production. For more information, see Delay Signing an Assembly.
- Company Name: A text field for your company name.
- Copyright: A text field for your company’s copyright statement.
- Key File: Sealing a management pack requires a key file that contains a private and public key. This validates the identity of the signing party and ensures that a malicious user cannot provide a sealed management pack impersonating someone else. This is the same key pair used for signing .NET assemblies and can be created with the Strong Name Tool (sn.exe) included with the Microsoft Windows SDK. For the complete usage of the Strong Name Tool, refer to its documentation.
The Output Path field specifies the location of the management pack after the build process is complete.
On the Management Group tab, you can select the management group where the management pack will be deployed. If the management group is not listed, click Add, and the Add Management Server dialog box appears. Once you’ve signed into the management server with the appropriate credentials, a list of available management groups is presented.
On the Deployment tab you’ll find various settings related to the deployment. Auto-increment version is selected by default, and is helpful for maintaining version control. The next version number is displayed; you can change it manually if necessary.
The Start action setting allows you to specify the action Visual Studio takes after building the project. The management pack can automatically deployed to a management group, and you can optionally start the Operations Console or the Web Console.
The Projects to deploy setting allows you to specify which projects to deploy: just the current MP, the MP and it’s dependencies, or all MPs in the solution.
Generating the Management Pack
To Build the project, select Build → Build Solution. The solution will be verified with various Visual Studio tools and the MP Verify tool. If any errors are found, an error list will be generated. If there are no errors, the Output window will be displayed, indicating that the build was successful. Depending on the configuration you set in the properties, the .xml or .mp file will be found in the directory you set. The default directory is:
C:\Users\username>\Documents\Visual Studio 2010\Projects\MP name>\MP name>\bin\Debug|Release]