Compartir a través de


How to Save a Management Pack

Applies To: System Center Service Manager 2010

Packaging the management pack can be done in two ways, by using a simple XML definition file or by using a management pack bundle. When you want to distribute the management pack as a whole, with all its resources, the bundle provides a single file for install and distribution. Otherwise, as a single XML file that is being distributed and eventually imported, you will have to manually import the resources along with it. The resources used by a bundle or XML file would be the external files distributed with the management pack, such as images, workflow, or user interface components.

To export the management pack as a single XML definition

  1. Create the management pack writer.

  2. Write the management pack to a directory.

When the XML file is created, it uses the name of the management pack as the file name. Instead of writing to a file directly as the example shows, you can write to a System.Xml.XmlWriter object by using the ManagementPackXmlWriter constructor. The following example demonstrates how to export the management pack XML.

string destinationDirectory = @".\";

ManagementPackXmlWriter mpWriter = new ManagementPackXmlWriter(destinationDirectory);
mpWriter.WriteManagementPack(mp);

Namespaces

Microsoft.EnterpriseManagement.Configuration

Microsoft.EnterpriseManagement.Configuration.IO

Microsoft.EnterpriseManagement.Packaging

Assemblies

Microsoft.EnterpriseManagement.Core

Microsoft.EnterpriseManagement.Packaging

To export the management pack as a bundle

  1. Create the bundle object from the bundle factory.

  2. Write the management pack.

When the bundle is created, it will have the file name extension of .mpb. A bundle is like a CAB file that contains all the files of the management pack in a single file. The bundle can also embed the required management pack resources by providing them in one of the constructor overloads of the write method. The following example demonstrates how to export a management pack bundle.

string destinationDirectory = @".\";
string bundleFileName = "RePackaging.Library";

ManagementPackBundle bundle = ManagementPackBundleFactory.CreateBundle();
ManagementPackBundleWriter bundleWriter = ManagementPackBundleFactory.CreateBundleWriter(destinationDirectory);

bundle.AddManagementPack(mp);
bundleWriter.Write(bundle, bundleFileName);

Namespaces

Microsoft.EnterpriseManagement.Configuration

Microsoft.EnterpriseManagement.Configuration.IO

Microsoft.EnterpriseManagement.Packaging

Assemblies

Microsoft.EnterpriseManagement.Core

Microsoft.EnterpriseManagement.Packaging