ResolveAssemblyReference keeps only one reference with the same assembly identity even if they have different aliases
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 141
Description
This was reported in a comment on a Visual Studio feedback item (I think the reporter was @rihadavid): https://developercommunity.visualstudio.com/content/problem/100351/c-extern-alias-reference-not-working-in-vs2017.html#comment-153540
In the repro project, there are two assemblies `Facebook.4.13.dll` and `Facebook4.27.dll`, both with assembly identity `Facebook, Version=4.10.0.0, Culture=neutral, PublicKeyToken=null`.
RAR sees both
```
Task "ResolveAssemblyReference" (TaskId:10)
Task Parameter:
Assemblies=
Facebook.4.13
Aliases=Facebook413
HintPath=.\Facebook.4.13.dll
Facebook.4.27, Version=4.10.0.0, Culture=neutral, processorArchitecture=MSIL
Aliases=Facebook427
HintPath=.\Facebook.4.27.dll
SpecificVersion=False
```
But follows only one:
```
Primary reference "Facebook, Version=4.10.0.0, Culture=neutral, PublicKeyToken=null". (TaskId:10)
Resolved file path is "S:\repro\devdiv\DevDiv\484390\ConsoleApp2\Facebook.4.27.dll". (TaskId:10)
Reference found at search path location "{CandidateAssemblyFiles}". (TaskId:10)
For SearchPath "{CandidateAssemblyFiles}". (TaskId:10)
Considered "Facebook.4.13.dll",
but its name "Facebook.4.13"
didn't match the expected name "Facebook, Version=4.10.0.0, Culture=neutral, PublicKeyToken=null". (TaskId:10)
The ImageRuntimeVersion for this reference is "v4.0.30319". (TaskId:10)
...
Output Item(s):
ReferencePath=
S:\repro\devdiv\DevDiv\484390\ConsoleApp2\Facebook.4.27.dll
Aliases=Facebook427
CopyLocal=true
FusionName=Facebook, Version=4.10.0.0, Culture=neutral, PublicKeyToken=null
HintPath=.\Facebook.4.27.dll
ImageRuntime=v4.0.30319
OriginalItemSpec=Facebook.4.27, Version=4.10.0.0, Culture=neutral, processorArchitecture=MSIL
ReferenceSourceTarget=ResolveAssemblyReference
ResolvedFrom={CandidateAssemblyFiles}
SpecificVersion=False
Version=4.10.0.0
```
Which then results in a compiler error
```
Program.cs(1,14): error CS0430: The extern alias 'Facebook413' was not specified in a /reference option [S:\repro\devdiv\DevDiv\484390\ConsoleApp2\ConsoleApp2.csproj]
```
because only one assembly+alias was passed to the compiler (`/reference:Facebook427=S:\repro\devdiv\DevDiv\484390\ConsoleApp2\Facebook.4.27.dll`).
If you manually bypass MSBuild and RAR, the compiler can handle the two assemblies.
This appears to be a very longstanding issue and not a regression; it repros in MSBuild `4.8.3921.0`, `14.0.23107.0`, and current (`16.5.0-preview-19570-01+9c33693c4`).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.