dotnet / dotnet/msbuild

MSB3277 When referencing a framework assembly with newer build or servicing version

Open
#12,780 0 comments 4 reactions 1 assignee Claimed by @MichalPavlik View on GitHub
Area: Task: Resolve Assembly References (RAR) triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

See https://github.com/dotnet/maintenance-packages/issues/243

.NET Framework assembly unification will ignore the last two digits for any assembly in the unification table. So even though the version from the package for previous framework is higher in build or servicing, the runtime will ignore that and still load the version from the GAC.

Ideally RAR would have this same behavior for .NETFramework assemblies in the targeting pack.

### Steps to Reproduce

[bclMem.zip](https://github.com/user-attachments/files/23590478/bclMem.zip)

Build attached

### Expected Behavior

No warnings

### Actual Behavior

Warn
```
C:\Program Files\dotnet\sdk\10.0.100-rtm.25476.104\Microsoft.Common.CurrentVersion.targets(2437,5): warning MSB3277:
Found conflicts between different versions of "System.ValueTuple" that could not be resolved.
There was a conflict between "System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "System.ValueTuple, Version=4.0.5.0, Culture=neutral, Pu
blicKeyToken=cc7b13ffcd2ddd51".
"System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was chosen because it was primary and "System.ValueTuple, Version=4.0.5.0, Culture=ne
utral, PublicKeyToken=cc7b13ffcd2ddd51" was not.
References which depend on "System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Fra
mework\.NETFramework\v4.7.2\Facades\System.ValueTuple.dll].
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\System.ValueTuple.dll
Project file item includes which caused reference "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\System.ValueTuple.dll"
.
System.ValueTuple
References which depend on or have been unified to "System.ValueTuple, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [].
C:\Users\ericstj\.nuget\packages\microsoft.bcl.memory\10.0.0\lib\net462\Microsoft.Bcl.Memory.dll
Project file item includes which caused reference "C:\Users\ericstj\.nuget\packages\microsoft.bcl.memory\10.0.0\lib\net462\Microsoft.Bcl.Memory.dll".
C:\Users\ericstj\.nuget\packages\microsoft.bcl.memory\10.0.0\lib\net462\Microsoft.Bcl.Memory.dll
```

### Analysis

I found that specifying `SpecificVersion="True"` will workaround this (perhaps unintentionally, since that seems to be the opposite of what I would expect) but it seems better if RAR would behave in the same way as the .NET Framework runtime.

### Versions & Configurations

Dotnet 10 SDK. Project targeting `net472` referencing `Microsoft.BCL.Memory` `10.0.0`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.