1

This must be a bug of the NuGet Package Manager I'm using (version 4.6.0). I used the option DependencyVersion highest but it always picks the lowest version for dependencies.

Like this (I'm trying to install Serilog.AspNetCore with dependencies of 2.2.0 - the latest but 2.0.0 is always picked).

install-package Serilog.AspNetCore -DependencyVersion highest

One dependency it picks is Microsoft.AspNetCore.Http.Abstractions 2.0.0 but I expected it to pick Microsoft.AspNetCore.Http.Abstractions 2.2.0. It's important because in my project the version 2.2.0 is required, Serilog should adapt that requirement by installing with that correct version of dependencies. But here I could not do anything to help it understand what I want.

Also the Install and Update options are not shown in the UI of NuGet Package Manager (the DependencyVersion could be selected there as well when using UI to install packages). So this appears to be some bug at least in the specific version of Nuget package manager I'm using.

What could I do to solve this issue? Can I try fixing the installed nuget manager (there is not any update in the Updates window).

Update

I've just tried a traditional .NET project, it works. But the problem raised when my projects target .NET Core (ASP.NET Core)? Looks like it does not support that feature for .NET Core projects?

halfer
  • 19,824
  • 17
  • 99
  • 186
Hopeless
  • 4,397
  • 5
  • 37
  • 64
  • Hi friend, any update for this issue? The `DependencyVersion ` doesn't support for projects using packageReference format, but maybe you can have a try my update. Hope it helps:) – LoLance Jun 26 '19 at 10:16

1 Answers1

0

The DependencyVersion switch is something used to control the behavior when NuGet looks for patch versions. It seems to be introduced after NuGet 2.8, but one point we should know is this option only supports packages.config format.

There are two package management formats:Projects.config and PackageReference.

1.For traditional .net project:It can use Packages.config or PackageReference to manage its nuget packages.But by default it uses packages.config.

2.For .net core projects(which uses new SDK-format project file):It uses new PackageReference format as its Package Management format.

More details about it see: Project Type Support

And someone had post this feature request in github, see the issue here.Hope it helps.

Update:

I expected it to pick Microsoft.AspNetCore.Http.Abstractions 2.2.0

Trying deleting the bin and obj folder first,

Then go Tools menu=>Nuget Package Manager=>Package Manager Settings=>Clear All Nuget Caches.(Sometimes it will delete the packages folder in C:\Users\lancel\.nuget\packages, we need to manually create a new packages folder)

Then install the Microsoft.AspNetCore.Http.Abstractions 2.2.0 package separately before installing the Serilog.AspNetCore package. Builds the application and you can check the output .dll by setting the CopyLocalLockFileAssemblies. In my machine it references 2.2.0 version of Microsoft.AspNetCore.Http.Abstractions.dll successfully. Hope it helps:)

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • Actually I accidentally made it install correctly without actually remembering the exact steps. That's why I did not care about this question anymore. There is one step that I unintentionally tried "Clear all nuget caches". That made me wait for a fairly long time before everything was re-fetched. However this time somehow the nuget cmd I had used before (with dependencyversion) worked. It's not complicated like you described. Although there might be some missing steps that I could not recall. Anyway thanks for your help. – Hopeless Jun 26 '19 at 11:13