uwpwindows-10-mobile

How to get programatically all capablities that enable in manifest for UWP app


I want to create a library, and I need to programmatically check to what capabilities enable in UWP app that use my library.

How to do it?


Solution

  • Reading the appxmanifest directly as a XML file is the way to go here. Something like this:

    var doc = XDocument.Load("AppxManifest.xml", LoadOptions.None);
    var xname = XNamespace.Get("http://schemas.microsoft.com/appx/manifest/foundation/windows10");
    var capabilitiesNode = doc.Root.Descendants(xname + "Capabilities").First();
    
    foreach (var capability in capabilitiesNode.Descendants())
    {
        Debug.WriteLine(capability.Name + ": " + capability.Attribute("Name").Value);
    }