ttugates
ttugates

Reputation: 6301

How can I configure nuget to not suggest Updates when Dependencies aren't met?

I have a number of projects inside a solution that are .netcoreapp11 based.

In Visual Studio Ver 15.5.6, with Nuget Package Manager Ver 4.5.0,

I have a page full of updates that show Dependencies on .NETStandard, Version=v2.0.

Trying to update any of them results in

Package Microsoft.AspNetCore.Server.Kestrel... 2.0.1 is not compatible with netcoreapp1.1

I am not in a position to move our Solution to .Net Core 2 at this time.

How do I configure my solution or nuget to not suggest updates I am unable to apply?

Upvotes: 0

Views: 78

Answers (1)

Leo Liu
Leo Liu

Reputation: 76880

How do I configure my solution or nuget to not suggest updates I am unable to apply?

I am afraid there is no such direct configuration for your solution or nuget to not suggest updates for all packages automatically.

That is because nuget only detect if there is a higher version in all nuget sources based on the version in the PackageReference rather than detect that the version to be upgraded is compatible with the Target framework. Only when we install nuget package to the project, nuget will detect whether this package is compatible with the Target framework. This is default design for nuget. So we could not direct configuration for the solution or nuget to not suggest updates before we install that packages.

To resolve this issue, there is a workaround that we could manually constrain nuget package upgrade versions for each package by specifying version range Version="[1.*, 2.0.0)":

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="[1.*, 2.0.0)" />
  </ItemGroup>

In this case, when nuget will not suggest update that package to version 2.0:

enter image description here

Note: You should use a * is the correct way to float to a higher version.

Hope this helps.

Upvotes: 1

Related Questions