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

AutoMapper 13.0.1与.NET 6.0兼容却报NU1202错误求助

AutoMapper 13.0.1安装报错NU1202的排查方案

几周前从NuGet下载的AutoMapper包运行正常,但现在安装AutoMapper 13.0.1时,一直弹出以下错误:

Severity Code Description Project File Line Suppression State Details
Error (active) NU1202 Package AutoMapper 13.0.1 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package AutoMapper 13.0.1 does not support any target frameworks.

根据官方信息,该版本完全兼容.NET 6.0,且我的项目确实基于.NET 6.0开发。这个错误在我电脑上所有.NET项目中都会出现,以下是其中一个项目的配置:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper" Version="13.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.32" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.32" />
    <PackageReference Include="Microsoft.AspNetCore.OData" Version="8.2.5" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.32">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.32" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
    <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.6.2" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" />
  </ItemGroup>

</Project>

可行排查步骤

  • 清理NuGet缓存:打开命令行执行 dotnet nuget locals all --clear,清除本地缓存后重新尝试安装包。
  • 检查NuGet源:确认使用的是官方NuGet源,避免镜像源或自定义源导致包元数据读取异常。可在Visual Studio的「工具」-「选项」-「NuGet包管理器」-「程序包源」中切换验证。
  • 更新NuGet客户端:确保Visual Studio的NuGet包管理器是最新版本,旧版本可能存在框架兼容性解析bug。
  • 手动安装包:下载AutoMapper 13.0.1的.nupkg文件,手动添加到项目中,验证是否能正常识别兼容框架。
  • 检查.NET SDK版本:执行 dotnet --list-sdks 查看本机.NET 6.0 SDK版本,若版本过低,更新至最新补丁版本。
  • 修复Visual Studio:尝试重置Visual Studio组件缓存,或通过安装程序修复IDE,排除IDE自身的解析故障。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 14:37:20