You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET MAUI编译报错:缺失AppxManifest.xml,VS2022如何自动生成?

解决.NET MAUI编译时自动生成AppxManifest.xml的问题

针对你的环境(Windows 10、.NET 6.0、Visual Studio 2022),可通过以下步骤解决AppxManifest.xml未自动生成的问题:

  • 检查并修正项目配置文件
    打开项目的.csproj文件,确认Windows相关的框架和SDK版本配置与已安装的Windows SDK匹配。示例配置如下:

    <TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst;net6.0-windows10.0.19041.0</TargetFrameworks>
    <TargetPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</TargetPlatformVersion>
    <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
    

    若不确定已安装的SDK版本,可通过Visual Studio的「工具→获取工具和功能」查看并安装对应版本的Windows 10 SDK。

  • 重置Windows项目配置

    1. 右键项目→卸载项目,右键编辑项目文件,删除所有手动添加的Windows相关自定义配置(如AppxManifest路径指定等),保存后重新加载项目。
    2. 右键项目→属性→Windows设置,确认「应用程序清单」字段为空(MAUI会自动生成该文件,无需手动指定),同时检查「生成Appx包」选项状态正常。
  • 彻底清理并重建项目

    1. 点击菜单栏「生成→清理解决方案」,手动删除项目根目录下的bin和obj文件夹。
    2. 重启Visual Studio,重新打开项目后选择Windows目标(如Windows Machine),执行「生成→重建解决方案」。
  • 验证MAUI工作负载完整性
    打开Visual Studio Installer,选择修改你的VS2022实例,确认「.NET Multi-platform App UI development」工作负载下的所有Windows相关组件(尤其是Windows SDK)已完整安装,无缺失项。

  • 检查位置权限配置
    由于你需要获取设备位置,确保项目中正确配置了Windows位置权限。可在.csproj中添加以下配置:

    <ApplicationCapability Name="location" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" />
    

    错误的权限配置可能导致manifest生成失败,这一步可排除此类问题。

内容的提问来源于stack exchange,提问作者Nandrew

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 22:50:06