Tried to downgrade from .net 5 to .net core 3.1 and now getting odd errors

Viewed 3671

I tried to downgrade from .net 5 to .net core 3.1. Now I have changed my mind and want to revert back to .net 5. Now I am getting odd errors when I try to install Nuget packages. What do I need to do? It is asking for Microsoft.CodeAnalysis.Common 3.8. But that package says "Do not install this package manually, it will be added as a prerequisite by other packages that require it".

Severity Code Description Project File Line Source Suppression State Error NU1107 Version conflict detected for Microsoft.CodeAnalysis.Common. Install/reference Microsoft.CodeAnalysis.Common 3.8.0 directly to project PROJECT to resolve this issue. PROJECT -> Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 5.0.2 -> Microsoft.CodeAnalysis.Razor 5.0.2 -> Microsoft.CodeAnalysis.Common (>= 3.8.0) PROJECT -> Telerik.UI.for.AspNet.Core 2021.1.119 -> Microsoft.CodeAnalysis 3.7.0 -> Microsoft.CodeAnalysis.CSharp.Workspaces 3.7.0 -> Microsoft.CodeAnalysis.Common (= 3.7.0). PROJECT C:\Users\ntimmerman\source\repos\PROJECT\PROJECT\PROJECT.csproj 1 IntelliSense

If I go ahead and install it anyway, I am left with warnings:

Severity Code Description Project File Line Source Suppression State Warning NU1608 Detected package version outside of dependency constraint: Microsoft.CodeAnalysis.CSharp.Workspaces 3.7.0 requires Microsoft.CodeAnalysis.Common (= 3.7.0) but version Microsoft.CodeAnalysis.Common 3.8.0 was resolved. PROJECT C:\Users\ME\source\repos\PROJECT\PROJECT\PROJECT.csproj 1 Build

The CSPROJ file is:

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

<PropertyGroup>
  <TargetFramework>net5.0</TargetFramework>
  <RootNamespace>PROJECT</RootNamespace>
  <UserSecretsId>SECRETID</UserSecretsId>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.2" />
  <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.2" />
  <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="5.0.2" />
   <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.2">
   <PrivateAssets>all</PrivateAssets>
   <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
  <PackageReference Include="Microsoft.Graph" Version="3.23.0" />
  <PackageReference Include="Microsoft.Identity.Web" Version="1.5.1" />
  <PackageReference Include="Microsoft.Identity.Web.UI" Version="1.5.1" />
  <PackageReference Include="Telerik.UI.for.AspNet.Core" Version="2021.1.119" />
</ItemGroup>

 <ItemGroup>
  <None Update="AdventureCycles-Logo.png">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </None>
 </ItemGroup>

</Project>
1 Answers

It's not really strange behaviour, the error messages are telling you what's wrong.

Your dependencies can have dependencies themselves, and those can change from version to version of the same package. If you have two dependencies on the same package with incompatible version ranges (in your case you've got a dependency on exactly version 3.7.0 of Microsoft.CodeAnalysis.Common, and what looks like another dependency on the same package with a range >= 3.8.0) then there's no way to satisfy both and it fails like this.

There's also no way to fix this other than to find the package with the conflicting dependency and reference another version of it which doesn't have this dependency (sounds like you've already done that)

Related