Mathiyazhagan
Mathiyazhagan

Reputation: 1429

Nuget Package Management issue - Unable to update the package in specific project

While compiling the Visual Studio solution I'm getting the below error. My specific project is looking for higher version(3.14.2), but the package it referenced is lower version. If i try to update from nuget package manager I'm getting an error, because another project looking for a lower version of this dll.

> Severity  Code    Description Project File    Line    Suppression State
> Error NU1605  Detected package downgrade:
> Microsoft.IdentityModel.Clients.ActiveDirectory from 3.14.2 to
> 2.21.301221612. Reference the package directly from the project to select a different version.   TestProj -> TestProj2 0.1.219 ->
> Microsoft.Azure.Services.AppAuthentication 1.1.0-preview ->
> Microsoft.IdentityModel.Clients.ActiveDirectory (>= 3.14.2)   TestProj
> -> TestProj2 0.1.219 -> Microsoft.IdentityModel.Clients.ActiveDirectory (>=
> 2.21.301221612)   Microsoft.Crm.ObjectModel   D:\Services\TestProj.csproj 1

In my repo, shared.props file contains like this

<PKG_ACTIVEDIR>$(CxCachePath)\Microsoft.IdentityModel.Clients.ActiveDirectory.2.29.0</PKG_ACTIVEDIR>

Packages.Props file contains

<PackageReference Update="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.19.8" />

Also I have 2 folders under Packages like

> microsoft.identitymodel.clients.activedirectory
> Microsoft.IdentityModel.Clients.ActiveDirectory.2.29.0

Now where should I set VersionOverride to override this version on specific project and what is the syntax for that

Upvotes: 0

Views: 767

Answers (1)

imps
imps

Reputation: 1661

You are in a situation where all the requirements of your project cannot be satisfied.

It's usually a bad practice to ignore the NU1605 warnings (it's a warning elevated to an error), see https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1605. Ignoring this warning can frequently lead to runtime errors. You essentially have components in your project that compiled against a higher version of the mentioned package. If you shove a lower version, you can end up with a runtime issue.

You have 2 options:

  • Solve the problem, actually use a higher version that your transitive reference requires (3.14.2). Update all your references of this package (transitive and direct to 3.14.2

  • Ignore the problem by suppressing the warning.

I don't think you need a version override here, the problem is not with the specified reference but with the transitive one.

Upvotes: 1

Related Questions