MAUI Windows应用restrictedcapabilities命名空间配置报错求助
解决MAUI Windows应用添加broadFileSystemAccess权限时的XML警告问题
这个警告的核心原因是默认的<Capabilities>节点属于基础Windows 10应用清单命名空间,不允许直接包含来自restrictedcapabilities命名空间的<rescap:Capability>元素。你需要把受限权限放到专门的<rescap:Capabilities>节点中,而非和普通权限混在默认节点里。
修改后的正确配置代码
<?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:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap"> <Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" /> <mp:PhoneIdentity PhoneProductId="EB2B3BD9-A87D-46D5-9338-702E53F5986D" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> <Properties> <DisplayName>$placeholder$</DisplayName> <PublisherDisplayName>User Name</PublisherDisplayName> <Logo>$placeholder$.png</Logo> </Properties> <Dependencies> <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" /> <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" /> </Dependencies> <Resources> <Resource Language="x-generate" /> </Resources> <Applications> <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$"> <uap:VisualElements DisplayName="$placeholder$" Description="$placeholder$" Square150x150Logo="$placeholder$.png" Square44x44Logo="$placeholder$.png" BackgroundColor="transparent"> <uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" /> <uap:SplashScreen Image="$placeholder$.png" /> </uap:VisualElements> </Application> </Applications> <!-- 存放普通权限的节点 --> <Capabilities> <!-- 例如 <Capability Name="internetClient" /> 这类常规权限可放在此处 --> </Capabilities> <!-- 受限权限必须单独放在rescap:Capabilities节点下 --> <rescap:Capabilities> <rescap:Capability Name="broadFileSystemAccess" /> </rescap:Capabilities>
额外注意事项
- 配置完成后,需手动在Windows系统设置中开启应用的文件系统权限:进入
设置 > 隐私和安全性 > 文件系统,找到你的MAUI应用并开启权限。 - 若要发布到Microsoft Store,
broadFileSystemAccess属于受限权限,需提交权限申请并获得微软批准才能上架;侧加载部署时,只要签名合法即可正常使用。
内容的提问来源于stack exchange,提问作者DaveR
相关产品推荐
相关产品推荐

