简体   繁体   中英

How to force downgrade a transative 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)

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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM