PackageReference conflict resolution craziness
See original GitHub issueI’m seeing issues with package versioning of transient packages using the PackageReference model. I found this entry in the build log, and this seems like a bug to me. A nuget package requires version 4.3.3, but then dotnet SDK grabs 4.2.0.0 because it’s greater than 4.1.1.2? That doesn’t make sense to me.
Is it a bug?
1> C:\Program Files\dotnet\sdk\2.1.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ConflictResolution.targets(41,5): message
NETSDK1041: Encountered conflict between 'Platform:System.Net.Http.dll' and 'CopyLocal:C:\Users\Joshua\.nuget\packages\system.net.http\4.3.3\lib\net46\System.Net.Http.dll'.
NETSDK1033: Choosing 'Platform:System.Net.Http.dll' because AssemblyVersion '4.2.0.0' is greater than '4.1.1.2'.
If I go to that first folder and look at both the file and product versions, they are 4.6.25707.1.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
NuGet Package Dependency Resolution
With packages.config , NuGet attempts to resolve dependency conflicts during the installation of each individual package.
Read more >Found conflicts between System.Net.Http
Migrate NuGet from packages.config to PackageReference as per the ... They just put it there to turn us crazy [citation needed].
Read more >Resolving Nuget dependency conflicts in Project SDK ...
Enter SDK style projects and PackageReference. PackageReference allows you to specify only a top level dependency, and all the transitive ...
Read more >How to resolve .NET reference and NuGet package version ...
If possible, resolve to a single reference version. The best solution is to remove the need for different reference versions.
Read more >NuGet PackageReference Versions SOLUTION Wide - YouTube
Having NuGet Packages across multiple projects can be a challenge. Each PackageRefence across csproj files must specify the same version of ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Messages in the log file about assembly version conflicts don’t generally mean there’s a problem. More or less, it simply means that there are references to different versions of the same library, and it needs to choose the best one.
Trying to understand what is happening can be further confused because there are a bunch of different version numbers a library can have. The NuGet package version, assembly version, and file version can be (and in some cases are) all different.
If you can enable automatic binding redirects in your projects, you should generally not have to worry about all of this. Automatic binding redirects aren’t supported for classic ASP.NET projects, so you may need to add a bunch of binding redirects to your web.config explicitly (which VS will do for you if you double-click the right warning in the error list).
Alternatively, if you are able to target .NET 4.7.2 or higher, I believe that most or all of these conflicts (and hence binding redirects) should go away.
FYI @joperezr in case you have more to add.
@dsplaisted IIRC, with a downlevel target framework (i.e., 4.6.2), build won’t copy the transient dependency and you get a runtime error on deployment. In a large solution environment with broadly-shared dependencies, it’s non-trivial to upgrade the target framework of a given library.