11
votes

Today this error ocurred again. Visual Studio does not recognize most of the packages instaled in Microsoft.AspNetCore.All but I'm also getting problems with:

  • Microsoft.Extensions.Logging.Debug
  • Microsoft.VisualStudio.Web.CodeGenerators.Mvc
  • Microsoft.EntityFrameworkCore.Tools.DotNet

The error message is like this for every package:

The Microsoft.VisualStudio.Web.CodeGenerators.Mvc 2.0.0 package is not compatible with netcoreapp2.0 (.NETCoreApp, Version = v2.0). The Microsoft.VisualStudio.Web.CodeGenerators.Mvc 2.0.0 package supports: netstandard2.0 (.NETStandard, Version = v2.0)

I got pass this issue before doing the following:

  • Updating VS to version 15.3.1
  • Updating SDK to version 2.0

Now, I have updated NuGet.Commandline to 4.3 but the problem persists.

I'm also getting this alert:

There is no way to resolve the conflict between "System.Collections.NonGeneric, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" and "System.Collections.NonGeneric, Version = 4.0.1.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a ". "System.Collections.NonGeneric, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" will be chosen arbitrarily. Application D: \ Visual Studio \ MSBuild \ 15.0 \ Bin \ Microsoft.Common.CurrentVersion.targets 1964

Any other update I shall look into? Any help is welcome. Thanks

4

4 Answers

11
votes

If you are using dotNET CLI, then just run this command,

dotnet nuget locals all --clear
5
votes

Solved by updating Visual Studio to version 15.3.3

It seems this will be happen often until aspnetcore2.0 stabilizes itself.

0
votes

I Solved it by clearing global-packages folder. Run either :

$ nuget locals global-packages -clear 

or

$ dotnet nuget locals global-packages --clear
0
votes

If anyone is getting this error or a similar error when running pipelines (builds) in Azure DevOps, then there is a different fix for that. In order to fix the pipeline, we had to add a NuGet tool installer task that forced the current build to use a version of NuGet >= 5.8.

Here is a screenshot of the task: enter image description here

For complete reference, here is the error message that we were getting on Azure DevOps pipeline:

Errors in G:...\ProjectName.Test.csproj Package Moq 4.12.0 is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Package Moq 4.12.0 supports: - net45 (.NETFramework,Version=v4.5)