.NET Framework迁移.NET 6 Core遇CS1705版本冲突求助
解决.NET 6迁移中CS1705程序集版本冲突问题
- 排查依赖链:在终端运行
dotnet list AdditionnalDataManagerAPI package,查看所有直接和传递依赖的版本,定位哪个包引入了8.0.0.0版本的Microsoft.Extensions.DependencyInjection.Abstractions。 - 强制统一版本:在AdditionnalDataManagerAPI项目的
.csproj文件中,直接添加该包的指定版本引用并开启自动绑定重定向:<ItemGroup> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" /> </ItemGroup> <PropertyGroup> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> </PropertyGroup> - 清理重建项目:手动删除项目根目录下的
bin和obj文件夹,依次执行dotnet clean、dotnet restore、dotnet build命令彻底重建。 - 同步类库版本:检查
Application类库项目的.csproj文件,确认它引用的Microsoft.Extensions.DependencyInjection.Abstractions版本。如果类库用的是8.0,要么把API项目升级到.NET 8(兼容.NET 6代码),要么把类库的该包版本降级到7.0,保持版本一致。 - 清空NuGet缓存:运行
dotnet nuget locals all --clear清空本地NuGet缓存,避免旧缓存干扰依赖还原。
内容的提问来源于stack exchange,提问作者belgacem aymen
相关产品推荐
相关产品推荐

