Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force downgrade a transitive dependency in dotnet core

My app called A depends on nuget library B, and nuget library C version 1.1.1 using PackageReference in the csproj.

<PackageReference Include="B" Version="1.0.0" />
<PackageReference Include="C" Version="1.1.1" />

However, Library B depends on Library C >= 1.1.2.

<PackageReference Include="C" Version="1.1.2" />

I cannot change my app to run on C version 1.1.2 and I know B will work fine with C version 1.1.1.

How do I force my app A to run using C version 1.1.1? Specifically I need to remove compiler error CS1705. Previously in full framework I would have used binding redirects but I understand these are not available in dotnet core.

A
- B
- C (v = 1.1.1)


B
- C (v >= 1.1.2)
like image 625
alastairtree Avatar asked Oct 28 '25 03:10

alastairtree


1 Answers

I'm not sure if this will fix your CS1705 issue, but to have the exact version of 1.1.1 for package C then you'd use Version Ranges.

eg. <PackageReference Include="C" Version="[1.1.1]" />

You can also try to use implicit versioning and let the build process decide that for you. You'd remove the Version attribute from the <PackageReference />

eg. <PackageReference Include="C" />

like image 187
Jimenemex Avatar answered Oct 30 '25 18:10

Jimenemex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!