7

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

Community
  • 1
  • 1
Adam Mac
  • 327
  • 2
  • 7
  • 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](https://learn.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations) 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. – Hans Passant Feb 21 '17 at 06:16
  • 1
    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 `` line. – Adam Mac Feb 21 '17 at 11:10
  • There is nothing wrong in your manifest. Perhaps your c ++ code asks for other capability. Could I touch your c++ code? – Nico Zhu Feb 22 '17 at 07:31
  • 1
    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, Adam – Adam Mac Feb 22 '17 at 16:50

2 Answers2

12

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,

Adam Mac
  • 327
  • 2
  • 7
7

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>
NoWar
  • 36,338
  • 80
  • 323
  • 498
Tedy Pranolo
  • 1,285
  • 1
  • 14
  • 22