Home > Mobile >  Not able to downgrade NuGet Package
Not able to downgrade NuGet Package

Time:12-07

I have a .NET 6 project that I want to downgrade to .NET 5, so I changed the target framework from 6 to 5.

<TargetFramework>net5.0</TargetFramework>

After doing so I got a lot of package compatibility errors which was expected, for example:

Package Microsoft.EntityFrameworkCore.Tools 6.0.5 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Package Microsoft.EntityFrameworkCore.Tools 6.0.5 supports: net6.0 (.NETCoreApp,Version=v6.0) 

However, when I try to downgrade the package using NuGet package manager or package manager console I get compatibility errors for all other packages and the package does not downgrade successfully. It seems like I cannot downgrade each package one by one and somehow I need to downgrade all packages at the same time.

Input:

Install-Package Microsoft.EntityFrameworkCore.Tools -Version 5.0.17

Output:

Install-Package : NU1202: Package Abp.AspNetCore.SignalR 7.2.1 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Package Abp.AspNetCore.SignalR 7.2.1 supports: net6.0 
(.NETCoreApp,Version=v6.0)
At line:1 char:1
  Install-Package Microsoft.EntityFrameworkCore.Design -Version 5.0.17
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
Install-Package : NU1202: Package Microsoft.AspNetCore.Authentication.JwtBearer 6.0.5 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Package 
Microsoft.AspNetCore.Authentication.JwtBearer 6.0.5 supports: net6.0 (.NETCoreApp,Version=v6.0)
At line:1 char:1
  Install-Package Microsoft.EntityFrameworkCore.Design -Version 5.0.17
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
Install-Package : NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 6.0.5 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Package Microsoft.EntityFrameworkCore.SqlServer 6.0.5 
supports: net6.0 (.NETCoreApp,Version=v6.0)
At line:1 char:1
  Install-Package Microsoft.EntityFrameworkCore.Design -Version 5.0.17
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
Install-Package : NU1202: Package Microsoft.EntityFrameworkCore 6.0.5 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Package Microsoft.EntityFrameworkCore 6.0.5 supports: net6.0 
(.NETCoreApp,Version=v6.0)
At line:1 char:1
  Install-Package Microsoft.EntityFrameworkCore.Design -Version 5.0.17
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
Install-Package : NU1202: Package Owl.reCAPTCHA 0.5.0 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Package Owl.reCAPTCHA 0.5.0 supports: net6.0 (.NETCoreApp,Version=v6.0)
At line:1 char:1
  Install-Package Microsoft.EntityFrameworkCore.Design -Version 5.0.17
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
Install-Package : Package restore failed. Rolling back package changes for 'ATC.Web.Host'.
At line:1 char:1
  Install-Package Microsoft.EntityFrameworkCore.Design -Version 5.0.17
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 

CodePudding user response:

I've had similar issues when upgrading certain packages. I go into the project file and edit the version numbers by hand.

CodePudding user response:

There is a reference relationship between the nuget packages you installed. So you get these errors when you use the command line Install-Package Microsoft.EntityFrameworkCore.Tools -Version 5.0.17.

As jmcilhinney said you can change the version of packages in .proj file, but you have to make sure that the modified version number is compatible with .net5. You can check the version and applicable frameworks in nuget.org.

Another solution to this problem is to uninstall all packages and reinstall the .net5 compatible version.

  • Related