UWP Manifest issue / restricted capability / inputForegroundObservation
Asked Answered
J

2

8

I'm trying to follow this StackOverflow article, referring to this similar article on StackOverflow, and this from the UWP Windows Dev Center.

In my manifest XML, the <Package> tag was updated to include xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" and also IgnorableNamespaces="uap mp wincap rescap".

My <Capabilities> section looks like this:

<Capabilities> <Capability Name="internetClient" /> <rescap:Capability Name="inputForegroundObservation" /> </Capabilities>

And <rescap:Capability is underlined with error:

"The element 'Capabilities'... has invalid child element...in...namespace.../windows10/restrictedcapabilities..."

(I snipped away much of the very long error message)

Any advice on how I can get the inputForegroundObservation Capability recognized? VS Community 2015 sp3, Microsoft.NETCore.UniversalWindowsPlatform package installed.

Cheers, Adam

Jargon answered 21/2, 2017 at 1:3 Comment(4)
It is just telling you that the restricted capability you are asking for is not declared in the schema. A warning, not a fatal error. That is not terribly surprising, the MSDN docs point out that this "is highly restricted and subject to additional Store onboarding policy and review". App submission has to be done specially and it takes up to 5 days longer to review your app. I suspect that if it looks anything at all like a key logger then your submission is going to be rejected.Nazler
Thanks for replying. Nothing nefarious; just a port of a very old C++ app that makes use of things like CTRL-A, C, J, X, Y, and Z - all of which seem to be handled outside the scope of the usual KeyDown event. I could change this in the app, but would rather keep its character intact. My test app still does not compile; gives a manifest validation error ("The app manifest XML must be valid") on the <Package> line.Jargon
There is nothing wrong in your manifest. Perhaps your c ++ code asks for other capability. Could I touch your c++ code?Theatre
Hi Nico - can I send you a zip file with the project (and how can I do this)? It's just a test project, to get the manifest and event handler working at a basic level, not the actual ported C++ code, which I'm developing separately for now. Cheers, AdamJargon
J
13

Answer:

  1. In the <package> tag, do not include wincap or rescap in IgnorableNameSpaces.
  2. You do not need a corporate account to build the app successfully and without error. I used the freely-downloadable Visual Studio Community 2015 fully updated as of 2017-03-03.
  3. The rescap:Capability Name= will continue to be underlined in the package XML editor, but this does not mean you will have any build warnings or errors.
  4. I put a comment in the MSDN documentation that says that rescap "must" be included in IgnorableNameSpaces - this was clearly throwing me off, and may well confuse others, also.
  5. More information here.

Hope this helps someone.

Cheers,

Jargon answered 4/3, 2017 at 1:7 Comment(0)
W
8

For Visual Studio 2019. The order is also important. I was putting the rescap:Capability last and kept getting the build error. It works if it's first, before other capabilities

From https://learn.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations#restricted-capabilities

All restricted capability elements must come before any CustomCapability and DeviceCapability elements under the Capabilities node in the package manifest.

For example

<Package  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  
...
    <Capabilities>
        <rescap:Capability Name="extendedBackgroundTaskTime"/>
        <Capability Name="internetClient" />
        <DeviceCapability Name="location"/>    
    </Capabilities>
</Package>
Witter answered 2/6, 2020 at 14:36 Comment(1)
Excelent answer, bro!Gawen

© 2022 - 2024 — McMap. All rights reserved.