Update #1: For information on enhanced detection methods, see this post.
Update #2: To avoid an exception being thrown in the administrator console, add the following code after line 12: application.DisplayInfo.DefaultLanguage = displayInfo.Language; (this has been fixed in ConfigMgr 2012 SP1)
Update #3: I have updated the sample as an attachment to this blog post so it can be more easily consumed.
Update #4: For information on requirement rules, see this post.
Update #5: For information on supersedence and dependencies, see this post.
I have seen quite a few questions being asked on how to create an application using the Configuratoin Manager 2012 SDK. Unfortunately the documentation has not yet been updated with this information so I am writing this post to provide some basic information to help you get started. This sample should compile and get you started but is by no means 100% functional.
What you will need:
- Microsoft.ConfigurationManagement.ApplicationManagement.dll — This assembly contains the application model object library
- Microsoft.ConfigurationManagement.ApplicationManagement.MsiInstaller.dll — This assembly contains the objects for a MSI or Script-based deployment type
These assemblies are part of the Administrator Console.
Here’s the code sample. It will create an application with a script-based deployment type, add content, and serialize to XML suitable for writing to the SMS Provider. This sample is only the application-specific portion and does not cover writing to the SMS Provider or how to deploy the application. I can provide this information in a follow-up post if there’s interest.
The first thing you’ll need to do is create an application object and add at least one AppDisplayInfo
This is enough to create a working application (you can call application.Validate() to confirm), but by itself it isn’t terribly useful since there’s no deployment types. The next thing you’ll need to do is add a deployment type, installer, and content:
After this is done, the serialized XML is appropriate for writing to an SMS_Application instance in the SMS Provider (the XML goes into the SDMPackageXML property). SMS_Application contains many lazy properties so you’ll want to re-Get the instance after creating it so the data is populated. This data will be needed to deploy the application to distribution points.
While not a complete end to end example, I hope this is a good starting point for anybody trying to create an application using the application model.