NuGet Package Manager attempting to add .NET 5.0 updates to .NET Core 3.1 application
See original GitHub issueWhen I go into Tools | NuGet Package Manager | Manage NuGet Package for Solution, it shows me there are 12 updates available.
But when I attempt to update them all, I get errors.
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration.Utils 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Utils 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
Package restore failed. Rolling back package changes for 'SolutionName'.
I can see there are incompatibility issues between .NET Core 3.1 and .NET 5.0 but I don’t know why.
Why is NuGet Package Manager trying to add .NET 5.0 updates to a .NET Core 3.1 application?
UPDATE
I kind of preferred to stay with .NET Core 3.1 but decided to try updating the project to .NET 5.0 and see what happened.
After updating the project, I tried to update the packages again. This time I get a different error.
System.NullReferenceException: Object reference not set to an instance of an object.
at NuGet.PackageManagement.UI.UIActionEngine.<>c.<ResolveActionsForUpdateAsync>b__9_0(PackageIdentity package)
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
at NuGet.PackageManagement.UI.UIActionEngine.<ResolveActionsForUpdateAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at NuGet.PackageManagement.UI.UIActionEngine.<>c__DisplayClass11_0.<<PerformActionImplAsync>b__0>d.MoveNext()
Time Elapsed: 00:00:00.0111119
========== Finished ==========
I’m really not sure why I’m getting any of these errors. Are there known issues? Can anyone help me understand why things aren’t working?
Note: Before upgrading my application to .NET Core, I also updated Visual Studio to version 16.8.2.
Further technical details
- ASP.NET Core version 3.1
- Visual Studio Version 16.8.0 (Windows 10)
.NET SDK (reflecting any global.json): Version: 5.0.100 Commit: 5044b93829
Runtime Environment: OS Name: Windows OS Version: 10.0.19041 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.100\
Host (useful for support): Version: 5.0.0 Commit: cf258a14b7
.NET SDKs installed: 3.1.401 [C:\Program Files\dotnet\sdk] 5.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Issue Analytics
- State:
- Created 3 years ago
- Comments:28 (14 by maintainers)
NuGet doesn’t block it, and it’s likely that it will work, but it’s not what we typically test. Your best bet is to use the latest patch NuGet packages that correspond to the major.minor of your target.
Has this been fixed? I feel like people forgot about this issue until now.