MSIX包Package.appmanifest中Capabilities元素警告问题求助
解决MSIX包Package.appmanifest中Capabilities元素的警告问题
问题说明
在MSIX包的Package.appmanifest文件中,以下<Capabilities>配置被标记警告:
<Capabilities> <Capability Name="internetClient" /> <rescap:Capability Name="runFullTrust" /> <rescap:Capability Name="localSystemServices" /> <rescap:Capability Name="packagedServices" /> </Capabilities>
警告详情
The element 'Capabilities' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' has invalid child element 'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities'. List of possible elements expected: 'CapabilityChoice' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' as well as 'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10' as well as 'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' as well as 'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10/4' as well as 'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10/6' as well as 'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10/7' as well as 'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10/3' as well as 'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10/2' as well as 'CustomCapabilityChoice' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' as well as 'CustomCapability' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10/4' as well as 'Dev....
完整清单代码
<?xml version="1.0" encoding="utf-8"?> <Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2" xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6" IgnorableNamespaces="uap rescap"> <Identity Name="11d14331-0000-0000-0000-3c2e4cc6d69d" Publisher="CN=my.name" Version="1.0.10.0" /> <Properties> <DisplayName>My Agent</DisplayName> <PublisherDisplayName>My</PublisherDisplayName> <Logo>Images\StoreLogo.png</Logo> </Properties> <Dependencies> <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" /> <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" /> </Dependencies> <Resources> <Resource Language="x-generate"/> </Resources> <Applications> <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$"> <uap:VisualElements DisplayName="My Agent" Description="My Agent." BackgroundColor="transparent" Square150x150Logo="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png"> <uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" /> <uap:SplashScreen Image="Images\SplashScreen.png" /> </uap:VisualElements> <Extensions> <desktop6:Extension Category="windows.service" EntryPoint="Windows.FullTrustApplication" Executable="Agent\Agent.exe"> <desktop6:Service Name="Agent" StartAccount="localSystem" StartupType="auto"/> </desktop6:Extension> </Extensions> </Application> </Applications> <Capabilities> <Capability Name="internetClient" /> <rescap:Capability Name="runFullTrust" /> <rescap:Capability Name="localSystemServices" /> <rescap:Capability Name="packagedServices" /> </Capabilities> <Extensions> <desktop2:Extension Category="windows.firewallRules"> <desktop2:FirewallRules Executable="Agent\Agent.exe"> <desktop2:Rule Direction="in" IPProtocol="TCP" Profile="all"/> <desktop2:Rule Direction="in" IPProtocol="UDP" Profile="all"/> <desktop2:Rule Direction="out" IPProtocol="TCP" Profile="all"/> <desktop2:Rule Direction="out" IPProtocol="UDP" Profile="all"/> </desktop2:FirewallRules> </desktop2:Extension> </Extensions> </Package>
解决方法
问题根源:默认的<Capabilities>元素仅接受基础命名空间或UAP命名空间的Capability子元素,受限功能(rescap命名空间下的Capability)不能直接嵌套在默认的<Capabilities>中,需要单独放在<rescap:Capabilities>节点内。
修改步骤:
- 保留原
<Capabilities>中的普通功能(如internetClient) - 在原
<Capabilities>节点之后,添加<rescap:Capabilities>节点,将所有rescap:Capability移至该节点下
修改后的Capabilities相关代码如下:
<Capabilities> <Capability Name="internetClient" /> </Capabilities> <rescap:Capabilities> <rescap:Capability Name="runFullTrust" /> <rescap:Capability Name="localSystemServices" /> <rescap:Capability Name="packagedServices" /> </rescap:Capabilities>
修改后重新编译项目,警告即可消除。
内容的提问来源于stack exchange,提问作者morleyc
相关产品推荐
相关产品推荐

