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

Microsoft.Maui.Essentials构建后自动降级 NU1605错误解决求助

解决MAUI项目中Microsoft.Maui.Essentials自动降级的NU1605错误

问题详情

项目CSPROJ配置中已指定:

<PackageReference Update="Microsoft.Maui.Essentials" Version="8.0.6" />

NuGet包管理器显示版本为8.0.6,但执行构建后版本自动变为8.0.3,触发错误:

Error NU1605 Warning As Error: Detected package downgrade: Microsoft.Maui.Essentials from 8.0.6 to 8.0.3. Reference the package directly from the project to select a different version.
AndroidAppCore -> Microsoft.Maui.Controls 8.0.6 -> Microsoft.Maui.Controls.Core 8.0.6 -> Microsoft.Maui.Core 8.0.6 -> Microsoft.Maui.Essentials (>= 8.0.6)

通过NuGet管理器重新升级后恢复正常,但清理并重新构建后问题重复出现。项目基础配置如下:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net8.0-android</TargetFrameworks>
    <SupportedOSPLatformVersion>23</SupportedOSPLatformVersion>
    <UseMaui>True</UseMaui>
    <UseMauiEssentials>true</UseMauiEssentials>

解决方案

1. 替换Update为Include强制直接引用

Update仅用于修改间接依赖的版本,优先级低于直接引用。将配置改为:

<PackageReference Include="Microsoft.Maui.Essentials" Version="8.0.6" />

直接声明依赖会让NuGet优先使用指定版本,避免被间接依赖的版本冲突覆盖。

2. 清理本地NuGet缓存

旧版本的包缓存可能导致版本解析异常,执行以下命令清理:

dotnet nuget locals all --clear

清理完成后重新还原包并构建。

3. 统一锁定MAUI核心包版本

确保项目中所有MAUI核心包(Microsoft.Maui.Controls、Microsoft.Maui.Core等)版本统一为8.0.6,避免跨版本依赖冲突。可以在CSPROJ的PropertyGroup中添加统一版本配置:

<MauiVersion>8.0.6</MauiVersion>

也可以通过Central Package Management(CPM)在Directory.Packages.props中统一管理版本:

<PackageVersion Include="Microsoft.Maui.Essentials" Version="8.0.6" />
<PackageVersion Include="Microsoft.Maui.Controls" Version="8.0.6" />

4. 检查依赖链定位冲突源

使用NuGet命令查看完整依赖树,确认是否有其他间接依赖强制引入8.0.3版本:

dotnet list package --include-transitive

如果发现有其他包依赖旧版本的Essentials,需要更新该包到兼容8.0.6的版本,或者排除其对Essentials的依赖:

<PackageReference Include="冲突包名称" Version="对应版本">
  <ExcludeAssets>all</ExcludeAssets>
  <PrivateAssets>all</PrivateAssets>
</PackageReference>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 02:56:05