SDK: How to create an application deployment type with a dependency on another application’s deployment type


Update: I was incorrect in my original statements around dependency and supersedence having equivalent code. I’ll post a future example covering supersedence.

This post expands on the original sample program to demonstrate how you would add a dependency or supersedence relationship with another application. The sample here has a notable difference from the “real world” in that you would typically load the application definition for a relationship from the provider to get the required data. The sample here just clones the existing application which should be enough to demonstrate the basic concepts here.

First use the sample in this post, then add this code after line 41:

// App to act as a dependency. For this demo, just clone the existing application so we have some metadata to use. 
// If this were a real world scenario you would create an app object from an existing one loaded from the provider.
Application dependentApp = (Application)application.Clone();
 
// DeploymentType to act as a dependency. As with the app, we're just cloning the existing one to have some metadata. If
// this were a real world scenario, you would use a DT that is in the app instance you loaded from the provider.
DeploymentType dependentDT = (DeploymentType)scriptDT.Clone();
dependentApp.DeploymentTypes.Add(dependentDT);
dependentDT.Title = "Dependency";
dependentApp.Validate();
 
// Create a collection for the operands for the expression
CustomCollection<DeploymentTypeIntentExpression> operands = new CustomCollection<DeploymentTypeIntentExpression>();
operands.Add(new DeploymentTypeIntentExpression(dependentApp.Scope, dependentApp.Name, dependentApp.Version.Value, dependentDT.Scope, dependentDT.Name, dependentDT.Version.Value, DeploymentTypeDesiredState.Required, true));
 
// Like with any requirement rule, you can chain multiple dependencies with "And" or "Or". In this sample there's only a single dependency so it doesn't really matter.
DeploymentTypeExpression expression = new DeploymentTypeExpression(ExpressionOperator.Or, operands);
DeploymentTypeRule dependencyRule = new DeploymentTypeRule("Dependency_" + Guid.NewGuid().ToString("B"), NoncomplianceSeverity.Critical, null, expression);
 
// We add this other DT as a dependency. Supersedence works the same way, except you use DeploymentType.Supersedes.Add() instead.
scriptDT.Dependencies.Add(dependencyRule);

When you execute the program, the application will contain the dependency details:

<Dependencies>
  <DeploymentTypeRule id="Dependency_{d95233f2-84ff-48c3-9761-ffc588a565fd}" Severity="Critical" xmlns="http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/06/14/Rules">
    <DeploymentTypeExpression>
      <Operator>Or</Operator>
      <Operands>
        <DeploymentTypeIntentExpression DesiredState="Required">
          <DeploymentTypeApplicationReference AuthoringScopeId="MyVendorId" LogicalName="Application_02ea9552-b1a6-43c9-82cf-97cfa5b0218b" Version="1" />
          <DeploymentTypeReference AuthoringScopeId="MyVendorId" LogicalName="DeploymentType_18ac74a8-781f-4bfd-940c-74e793b58a9d" Version="1" Changeable="true" />
        </DeploymentTypeIntentExpression>
      </Operands>
    </DeploymentTypeExpression>
  </DeploymentTypeRule>
</Dependencies>

Supersedence follows the exact same concepts except instead of adding to the Dependencies collection, you’re adding your rule to the Supersedence collection.

Download sample program Program.cs

Comments (7)

  1. Anthony says:

    Hi I am looking to rip the properties and settings out of individual folders that were pre-packaged and prepaired for SCCM 2012.

    • I have very limited access and am only able to create applications.

    Really tryingto speed the migration to System Center 2012 Configuration

    Manager and the new application model, including a bulk import migrating

    applications.

    I need it to detirmen application deployment metadata by mining package elements like system requirements, detection methods and dependence on other applications such as .NET,

    then populating the fields and pop-ip prompting you if you miss somthing or if it cant rip the data from that applications folder.

    The last thing that adds a little twist is that since these are custom packaged by our abu factory, we are not using msi's as a standard  but command files that are wrapped to unclude the custom switches.

    Any help would be greatly appreciated. If you really wanna dig into this I could probably pay you a few hundred.

    Let me know , thanks.

    Anthony aharwelik@bluetechgreen.com

  2. Vinod Kumar Pittampally says:

    Hi Adam,

    Is there a method available to add Supersedence to the deployment type(s). I see that the text related to Supersedance is striken in this post.

    Thanks

    Vinod

  3. KumarMudedla says:

    Hello Adam Meltzer,

    This example works well except it wont add the  "Dependency Group Name" so when ever we go and check in the sccm 2012 console we will get an error that the Dependency group is required.

    Can you please tell me how to add the dependency group. Do we have add that in the expression?

    I really appreciate if can help me on this.

  4. Hello Adam Meltzer,

    The above example works fine but it is not adding any "Dependency Group name"

    Can you please let me know where i have to add the Dependency group Name ?

    thank you

  5. Clayton Olney says:

    I'm wondering when/if you plan to publish anything on supersedence?

  6. Flemming Appelon Christiansen says:

    "Dependency Group name" is set by setting the Name property on the DeploymentRuleType:

    dependencyRule.Name = "My dependency group";

  7. Pascal says:

    Set dependentDT.Version.Value to 0

    If not, if the dependancy changing, the new revision is not dependent of application and your deployment will be broken

Skip to main content